Method
Synchronized::run
Runs $closure once no other coroutine runs a closure for $token, and returns what it returns.
Description#
public static Synchronized::run(
object|string $token,
Closure $closure
): mixedParameters#
- $token object|string
- The name of the lock; an object stands for itself
- $closure Closure
- What to run with the lock held
Return values#
What $closure returned mixed
Errors / Exceptions#
| Exception | When |
|---|---|
LogicException | If the coroutine that holds the lock asks for it again |
Throwable | What $closure threw |