PHP 8.1.0 RC 4 available for testing


(PECL pht >= 0.0.1)

pht\Queue::lockAcquires the queue's mutex lock


public pht\Queue::lock(): void

This method will acquire the mutex lock associated with the queue. The mutex lock should always be acquired when manipulating the queue if it is being used by multiple threads.

The mutex locks of the Inter-Thread Communication (ITC) data structures are not reentrant. Attempting to reacquire an already-acquired mutex lock by the same thread will therefore cause a deadlock.

Liste de param├Ętres

Cette fonction ne contient aucun param├Ętre.

Valeurs de retour

No return value.


Exemple #1 Locking a queue's mutex lock


use pht\{ThreadQueue};

$thread = new Thread();
$queue = new Queue();

$thread->addFunctionTask(function ($queue) {


// $queue is currently being used by multiple threads


// $queue is only being used in this thread now, so no need to lock it
while ($queue->size()) {

L'exemple ci-dessus va afficher :


add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top