Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<Swoole\Coroutine\Lock::__constructSwoole\Coroutine\Lock::trylock>
^Swoole\Coroutine\LockLast updated: Mon, 26 Oct 2026

Swoole\Coroutine\Lock::lock

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

Swoole\Coroutine\Lock::lock — Acquire the lock, blocking if necessary

Description

public function 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

This function has no parameters.

Return Values

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


<Swoole\Coroutine\Lock::__constructSwoole\Coroutine\Lock::trylock>
^Swoole\Coroutine\LockLast updated: Mon, 26 Oct 2026