00001 <?php 00002 /*************************************************************************** 00003 * Copyright (C) 2005-2007 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 /* $Id: SemaphorePool.class.php 4687 2007-12-09 18:57:18Z voxus $ */ 00012 00023 final class SemaphorePool extends BaseLocker implements Instantiatable 00024 { 00025 private static $lockerName = 'SystemFiveLocker'; 00026 private static $locker = null; 00027 00028 protected function __construct() 00029 { 00030 self::$locker = Singleton::getInstance(self::$lockerName); 00031 } 00032 00033 public static function setDefaultLocker($name) 00034 { 00035 Assert::isTrue(class_exists($name, true)); 00036 00037 self::$lockerName = $name; 00038 self::$locker = Singleton::getInstance($name); 00039 } 00040 00044 public static function me() 00045 { 00046 return Singleton::getInstance(__CLASS__); 00047 } 00048 00049 public function get($key) 00050 { 00051 return self::$locker->get($key); 00052 } 00053 00054 public function free($key) 00055 { 00056 return self::$locker->free($key); 00057 } 00058 00059 public function drop($key) 00060 { 00061 return self::$locker->drop($key); 00062 } 00063 00064 public function clean() 00065 { 00066 return self::$locker->clean(); 00067 } 00068 00069 public function __destruct() 00070 { 00071 self::$locker->clean(); 00072 } 00073 } 00074 ?>