Flock based lock implementation.

  • see http://php.net/manual/en/function.flock.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.
public Google\Cloud\Core\Lock\FlockLock::FILE_PATH_TEMPLATE = '%s/%s.lock'
public __construct( $fileName, array $options = [])
  • throws InvalidArgumentException If an invalid fileName is provided.
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

  • return mixed
private $exclusive
  • var bool If true, we should acquire an exclusive lock.
private $filePath
  • var string
private $handle
  • var resource|null
private initializeHandle()

Initializes the handle.

  • return resource
  • throws RuntimeException If the lock file fails to open.
private lockType(array $options)
© 2020 Bruce Wells
Search Namespaces \ Classes
ConfigurationNumbers (0-9.) only