Swoole\Coroutine\Lock::trylock

(No version information available, might only be in Git)

Swoole\Coroutine\Lock::trylockAttempt to acquire the lock without blocking

说明

public Swoole\Coroutine\Lock::trylock(): bool

When calling the lock operation, if the lock is already held by another coroutine, the function will immediately return false without suspending the current coroutine or yielding CPU control. This non-blocking design allows the caller to flexibly handle contention situations, such as retrying, giving up, or executing other logic.

参数

此函数没有参数。

返回值

Returns true if the lock was acquired successfully, false if the lock is not available.

添加备注

用户贡献的备注

此页面尚无用户贡献的备注。
To Top