This is automatic generated document for things in Swow\Mutex class
Class Mutex
A mutex that works across threads.
The mutex is not recursive. The owner is a thread. A mutex stays locked when the owner thread exits. Do not destroy a locked mutex. Destruction of a locked mutex emits a warning.
Methods
Method __construct
Create a mutex.
Method __debugInfo
Return debug information.
Method __serialize
Serialize the mutex by shared object id.
The serialized form does not copy the mutex state.
Throws \Swow\SyncException when the mutex is not constructed.
Method __unserialize
Restore the mutex from a shared object id.
Throws \Swow\SyncException when the data is invalid or the object is gone.
Method lock
Take the mutex.
In a coroutine, this method suspends the current coroutine when the mutex is held. Do not lock the same mutex twice from one thread. The second call waits and can deadlock.
context switching may happen here
Param int $timeout timeout in milliseconds, -1 waits forever
Returns bool false on timeout
Throws \Swow\SyncException when the caller cannot wait for the mutex.
Method unlock
Release the mutex.
The caller must hold the mutex.
Throws \Swow\SyncException when the caller does not hold the mutex.