Threaded::notify

(PECL pthreads >= 2.0.0)

Threaded::notifySynchronisation

Description

public Threaded::notify ( void ) : bool

Envoi une notification à l'objet référencé

Liste de paramètres

Cette fonction ne contient aucun paramètre.

Valeurs de retour

Un booléen indiquant le succès

Exemples

Exemple #1 Notifications et attente

<?php
class My extends Thread {
    public function 
run() {
        
/** fait que le thread patiente **/
        
$this->synchronized(function($thread){
            if (!
$thread->done)
                
$thread->wait();
        }, 
$this);
    }
}
$my = new My();
$my->start();
/** envoi la notification au thread qui attend **/
$my->synchronized(function($thread){
    
$thread->done true;
    
$thread->notify();
}, 
$my);
var_dump($my->join());
?>

L'exemple ci-dessus va afficher :

bool(true)