Icicle\Concurrent\Threading\Internal\Mutex::acquire PHP Method

acquire() public method

Attempts to acquire the lock and sleeps for a time if the lock could not be acquired.
public acquire ( ) : Generator
return Generator
    public function acquire() : \Generator
    {
        $tsl = function () {
            return $this->lock ? $this->lock = false : true;
        };
        while (!$this->lock || $this->synchronized($tsl)) {
            yield from Coroutine\sleep(self::LATENCY_TIMEOUT);
        }
        return new Lock(function () {
            $this->release();
        });
    }

Usage Example

示例#1
0
 /**
  * {@inheritdoc}
  */
 public function acquire()
 {
     return $this->mutex->acquire();
 }
All Usage Examples Of Icicle\Concurrent\Threading\Internal\Mutex::acquire