lock = $lock; } /** * Acquires a lock that will block until released. * * @param array $options [optional] { * Configuration options. * * @type bool $blocking Whether the process should block while waiting * to acquire the lock. **Defaults to** true. * } * @return bool * @throws \RuntimeException If the lock fails to be acquired. */ public function acquire(array $options = []) { $options += [ 'blocking' => true ]; try { return $this->lock->acquire($options['blocking']); } catch (\Exception $ex) { throw new \RuntimeException( sprintf( 'Acquiring the lock failed with the following message: %s', $ex->getMessage() ), 0, $ex ); } } /** * Releases the lock. * * @throws \RuntimeException */ public function release() { try { $this->lock->release(); } catch (\Exception $ex) { throw new \RuntimeException( sprintf( 'Releasing the lock failed with the following message: %s', $ex->getMessage() ), 0, $ex ); } } }