php8.5
Home/ Manual/ coroutine / lock/ Swoole\Coroutine\Lock::lock

Swoole\Coroutine\Lock::lock

PHP function Edit on GitHub ✎

Acquire the lock, blocking if necessary

Description

Swoole\Coroutine\Lock::lock(): bool

When executing the lock operation, if the lock is already held by another coroutine, the current coroutine will actively yield CPU control and enter a suspended state. When the coroutine holding the lock calls unlock(), the waiting coroutine will be awakened and try to acquire the lock again.

Parameters Parameters

Return Values

Returns true if the lock was acquired successfully, false otherwise.

Source: reference/swoole/swoole/coroutine/lock/lock.xml · from the official PHP manual (php/doc-en)