Threaded::wait

(PECL pthreads >= 2.0.0)

Threaded::waitSynchronisation

Description

publicThreaded::wait(int$timeout = ?): bool

Fera attendre le contexte appelant une notification depuis l'objet référencé.

Liste de paramètres

timeout

Un délai d'attente maximal optionnel, en microsecondes.

Valeurs de retour

Cette fonction retourne true en cas de succès ou false si une erreur survient.

Exemples

Exemple #1 Notifications et attente

<?php
class My extends Thread {
public function
run() {

$this->synchronized(function($thread){
if (!
$thread->done)
$thread->wait();
},
$this);
}
}
$my = new My();
$my->start();

$my->synchronized(function($thread){
$thread->done = true;
$thread->notify();
},
$my);
var_dump($my->join());
?>

L'exemple ci-dessus va afficher :

bool(true)
To Top