Method
LockTrait::lock
Runs $callable while holding the lock of this object, and returns what it returns.
Description#
public LockTrait::lock(
Closure $callable,
?float $timeout = null
): mixedThe lock is reentrant for the coroutine that holds it. Other coroutines wait, and get it in the order they asked.
Parameters#
- $callable Closure
- What to run with the lock held
- $timeout ?float = null
- Seconds to wait for the lock at most; null: no limit
Return values#
What $callable returned mixed
Errors / Exceptions#
| Exception | When |
|---|---|
TimeoutException | If the lock was not acquired in time |
Throwable | What $callable threw |