(PECL pthreads >= 2.0.0)
Threaded::wait — Sincronización
Hace esperar al contexto llamante una notificación desde el objeto referenciado.
timeout
Un tiempo de espera máximo opcional, en microsegundos.
Ejemplo #1 Notificaciones y espera
<?php
class My extends Thread {
public function run() {
/** Hace esperar este hilo **/
$this->synchronized(function($thread){
if (!$thread->done)
$thread->wait();
}, $this);
}
}
$my = new My();
$my->start();
/** Envía la notificación al hilo que espera **/
$my->synchronized(function($thread){
$thread->done = true;
$thread->notify();
}, $my);
var_dump($my->join());
?>
El resultado del ejemplo sería:
bool(true)