Home
My Account
About us
Products
Support Services
Buy online
Downloads
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
PHP Manual
Swoole
Installing/Configuring
Predefined Constants
Swoole Functions
Swoole\Async
Swoole\Atomic
Swoole\Buffer
Swoole\Channel
Swoole\Client
Swoole\Connection\Iterator
Swoole\Coroutine
Swoole\Coroutine\Lock
Swoole\Event
Swoole\Exception
Swoole\Http\Client
Swoole\Http\Request
Swoole\Http\Response
Swoole\Http\Server
Swoole\Lock
Swoole\Mmap
Swoole\Module
Swoole\MySQL
Swoole\MySQL\Exception
Swoole\Process
Swoole\Redis\Server
Swoole\Runtime
Swoole\Serialize
Swoole\Server
Swoole\Table
Swoole\Timer
Swoole\WebSocket\Frame
Swoole\WebSocket\Server
Swoole\Http\Server::start
Swoole\Lock::__construct
Swoole
Last updated: Mon, 26 Oct 2026
The Swoole\Lock class
(PECL swoole >= 1.9.0)
Introduction
Class synopsis
class
Swoole\Lock
{
/* Methods */
public
function
__destruct
():
void
public
function
lock
():
void
public
function
lock_read
():
void
public
function
trylock
():
void
public
function
trylock_read
():
void
public
function
unlock
():
void
}
Table of Contents
Swoole\Lock::__construct
— Construct a memory lock.
Swoole\Lock::__destruct
— Destroy a Swoole memory lock.
Swoole\Lock::lock
— Try to acquire the lock. It will block if the lock is not available.
Swoole\Lock::lock_read
— Lock a read-write lock for reading.
Swoole\Lock::trylock
— Try to acquire the lock and return straight away even the lock is not available.
Swoole\Lock::trylock_read
— Try to lock a read-write lock for reading and return straight away even the lock is not available.
Swoole\Lock::unlock
— Release the lock.
Swoole\Http\Server::start
Swoole\Lock::__construct
Swoole
Last updated: Mon, 26 Oct 2026