$this->keySha1 = sha1( $this->key );
$met = ini_get( 'max_execution_time' ); // usually 0 in CLI mode
- $this->lockTTL = $met ? 2*$met : 3600;
+ $this->lockTTL = $met ? 2 * $met : 3600;
if ( self::$active === null ) {
self::$active = array();
}
function acquireForMe() {
- $section = new ProfileSection( __METHOD__ );
+
+ $status = $this->precheckAcquire();
+ if ( !$status->isGood() ) {
+ return $status;
+ }
return $this->waitForSlotOrNotif( self::AWAKE_ONE );
}
function acquireForAnyone() {
- $section = new ProfileSection( __METHOD__ );
+
+ $status = $this->precheckAcquire();
+ if ( !$status->isGood() ) {
+ return $status;
+ }
return $this->waitForSlotOrNotif( self::AWAKE_ALL );
}
function release() {
- $section = new ProfileSection( __METHOD__ );
if ( $this->slot === null ) {
return Status::newGood( PoolCounter::NOT_LOCKED ); // not locked
$this->onRelease = null;
unset( self::$active[$this->session] );
+ $this->onRelease();
+
return Status::newGood( PoolCounter::RELEASED );
}
self::$active[$this->session] = $this;
}
+ $this->onAcquire();
+
return Status::newGood( $slot === 'w' ? PoolCounter::DONE : PoolCounter::LOCKED );
}