/** * Constructor. * * @param string $name The mutex name. */ public function __construct($name) { assert('is_string($name)'); $this->name = $name; $path = dirname(__FILE__) . DIRECTORY_SEPARATOR; //Path to ./mutex if (is_null(self::$type)) { foreach ($this->types as $type) { $classFile = $path . $type . 'Mutex.class.php'; if (file_exists($classFile)) { require_once $classFile; $className = $type . 'Mutex'; if (class_exists($className)) { $method = array($className, 'canInstantiate'); if (is_callable($method) && call_user_func($method)) { self::$type = $type; $this->mutex = new $className($name); break; } } } } if (is_null(self::$type)) { throw new MutexException('Sorry but I can\'t create a mutex on this system, please consider installing the Semaphore extension or at least making flock() work.'); } } else { $className = self::$type . 'Mutex'; $this->mutex = new $className($name); } }