Semaphore based lock implementation.

  • see http://php.net/manual/en/book.sem.php
  • experimental The experimental flag means that while we believe this method or class is ready for use, it may change before release in backwards- incompatible ways. Please use with caution, and test thoroughly when upgrading.
CloneableInstantiable
ImplementsGoogle\Cloud\Core\Lock\LockInterface
Methods
public __construct( $key)
 
  • throws InvalidArgumentException If an invalid key is provided.
  • throws RuntimeException If the System V IPC extensions are missing.
public acquire(array $options = [])
 

Acquires a lock that will block until released.

  • return bool
  • throws RuntimeException If the lock fails to be acquired.
public release()
 

Releases the lock.

  • throws RuntimeException If the lock fails to release.
public synchronize(callable $func, array $options = [])
 

Execute a callable within a lock. If an exception is caught during
execution of the callable the lock will first be released before throwing
it.

  • return mixed
Properties
private $key
 
  • var int
private static $productionKey = 'P'
private $semaphoreId
 
  • var resource|null
private static $typeDirect = 1
private static $typeFile = 2
Methods
private getSysvKey( $idNum)
 

Create a SystemV IPC key for the given id number.

Set GOOGLE_CLOUD_SYSV_ID envvar to change the base id.

  • return int
private initializeId()
 

Initializes the semaphore ID.

  • return resource
  • throws RuntimeException If semaphore ID fails to generate.
private isSysvIPCLoaded()
 

Determine whether the SystemV IPC extension family is loaded.

  • return bool
Properties
private static $productionKey = 'P'
private static $typeDirect = 1
private static $typeFile = 2
© 2020 Bruce Wells
Search Namespaces \ Classes
ConfigurationNumbers (0-9.) only