function mutex($id,$func,$args=NULL) {
		if (!is_dir($tmp=$this->hive['TEMP']))
			mkdir($tmp,self::MODE,TRUE);
		// Use filesystem lock
		if (is_file($lock=$tmp.
			$this->get('SEED').'.'.$this->hash($id).'.lock') &&
			filemtime($lock)+ini_get('max_execution_time')<microtime(TRUE))
			// Stale lock
			@unlink($lock);
		while (!($handle=@fopen($lock,'x')) && !connection_aborted())
			usleep(mt_rand(0,100));
		$this->locks[$id]=$lock;
		$out=$this->call($func,$args);
		fclose($handle);
		@unlink($lock);
		unset($this->locks[$id]);
		return $out;
	}
function mutex($id,$func,$args=NULL) {
		if (!is_dir($tmp=$this->hive['TEMP']))
			mkdir($tmp,self::MODE,TRUE);
		// Use filesystem lock
		if (is_file($lock=$tmp.
			$this->get('SEED').'.'.$this->hash($id).'.lock') &&
			filemtime($lock)+ini_get('max_execution_time')<microtime(TRUE))
			// Stale lock
			@unlink($lock);
		while (!($handle=@fopen($lock,'x')) && !connection_aborted())
			usleep(mt_rand(0,100));
		$this->locks[$id]=$lock;
		$out=$this->call($func,$args);
		fclose($handle);
		@unlink($lock);
		unset($this->locks[$id]);
		return $out;
	}
function mutex ( $ id , $ func , $ args = NULL ) { if ( ! is_dir ( $ tmp = $ this -> hive [ 'TEMP' ] ) ) mkdir ( $ tmp , self :: MODE , TRUE ) ; // Use filesystem lock if ( is_file ( $ lock = $ tmp . $ this -> get ( 'SEED' ) . '.' . $ this -> hash ( $ id ) . '.lock' ) && filemtime ( $ lock ) + ini_get ( 'max_execution_time' ) < microtime ( TRUE ) ) // Stale lock @ unlink ( $ lock ) ; while ( ! ( $ handle = @ fopen ( $ lock , 'x' ) ) && ! connection_aborted ( ) ) usleep ( mt_rand ( 0 , 100 ) ) ; $ this -> locks [ $ id ] = $ lock ; $ out = $ this -> call ( $ func , $ args ) ; fclose ( $ handle ) ; @ unlink ( $ lock ) ; unset ( $ this -> locks [ $ id ] ) ; return $ out ; }
Create mutex, invoke callback then drop ownership when done
@return mixed
@param $id string
@param $func callback
@param $args mixed
Create mutex invoke callback then drop ownership when done