Mutex
in package
FinalYes
If a mutex is yielded without calling `lock()`, the Workflow will continue only when the lock is released.
$this->mutex = new Mutex();
// Continue only when the lock is released
yield $this->mutex;
Table of Contents
Properties
Methods
- isLocked() : bool
- Check if the mutex is locked.
- lock() : PromiseInterface<string|int, self>
- Lock the mutex.
- tryLock() : bool
- Try to lock the mutex.
- unlock() : void
- Release the lock.
Properties
$locked
private
bool
$locked
= false
$waiters
private
array<string|int, Deferred>
$waiters
= []
Methods
isLocked()
Check if the mutex is locked.
public
isLocked() : bool
Return values
boollock()
Lock the mutex.
public
lock() : PromiseInterface<string|int, self>
// Continue only when the lock is acquired
yield $this->mutex->lock();
Return values
PromiseInterface<string|int, self> —A promise that resolves when the lock is acquired.
tryLock()
Try to lock the mutex.
public
tryLock() : bool
Return values
bool —Returns true if the mutex was successfully locked, false otherwise.
unlock()
Release the lock.
public
unlock() : void