|
The Swoole\Coroutine\Lock classIntroductionSwoole 6.0.1 introduced a coroutine lock that supports inter-process and inter-thread sharing. This lock is designed with non-blocking behavior and enables efficient coroutine synchronization in multi-process and multi-thread environments.
When compiled with the
Without The coroutine lock is reentrant, allowing the currently holding coroutine to safely perform multiple lock operations. Warning
Do not create locks in callback functions like Warning
Locking and unlocking must be performed in the same coroutine, otherwise it will break static conditions. Class synopsisSwoole\Coroutine\Lock
class Swoole\Coroutine\Lock
{
/* Methods */
public void __construct()
public bool lock()
public bool trylock()
public bool unlock()
}ExamplesExample #1 Basic usage
|