downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

Modifiers> <Stackable::unlock
[edit] Last updated: Fri, 07 Jun 2013

view this page in

Stackable::wait

(PECL pthreads >= 0.36)

Stackable::waitSynchronization

Descripción

final public boolean Stackable::wait ([ string $timeout ] )

Waits for notification from the Stackable

Parámetros

timeout

An optional timeout in millionths of a second.

Valores devueltos

A boolean indication of success

Ejemplos

Ejemplo #1 Notifications and Waiting

<?php
class Work extends Stackable {
    public function 
run() {
        
$this->synchronized(function($object){
        
printf("%s Synchronized\n"__CLASS__);    
        
$object->notify();
        }, 
$this);
    }
}
class 
My extends Worker {
    public function 
run() {
        
/** ... **/
    
}
}

$my = new My();
$my->start();
$work = array(new Work());
$my->stack($work[0]);
/** send notification to the waiting thread **/
$work[0]->synchronized(function($object){
    
printf("Process Synchronized\n");
    
$object->wait();
}, 
$work[0]);
?>

El resultado del ejemplo sería:

Process Synchronized
Work Synchronized



add a note add a note User Contributed Notes Stackable::wait - [0 notes]
There are no user contributed notes for this page.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites