SemaphorePool.class.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************************
00003  *   Copyright (C) 2005-2008 by Konstantin V. Arkhipov                     *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License as        *
00007  *   published by the Free Software Foundation; either version 3 of the    *
00008  *   License, or (at your option) any later version.                       *
00009  *                                                                         *
00010  ***************************************************************************/
00011 
00022     final class SemaphorePool extends BaseLocker implements Instantiatable
00023     {
00024         private static $lockerName  = 'DirectoryLocker';
00025         private static $locker      = null;
00026         
00027         protected function __construct()
00028         {
00029             self::$locker = Singleton::getInstance(self::$lockerName);
00030         }
00031         
00032         public static function setDefaultLocker($name)
00033         {
00034             Assert::classExists($name);
00035             
00036             self::$lockerName = $name;
00037             self::$locker = Singleton::getInstance($name);
00038         }
00039         
00043         public static function me()
00044         {
00045             return Singleton::getInstance(__CLASS__);
00046         }
00047         
00048         public function get($key)
00049         {
00050             return self::$locker->get($key);
00051         }
00052         
00053         public function free($key)
00054         {
00055             return self::$locker->free($key);
00056         }
00057         
00058         public function drop($key)
00059         {
00060             return self::$locker->drop($key);
00061         }
00062         
00063         public function clean()
00064         {
00065             return self::$locker->clean();
00066         }
00067         
00068         public function __destruct()
00069         {
00070             self::$locker->clean();
00071         }
00072     }
00073 ?>