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

search for in the

Stackable::unlock> <Stackable::run
[edit] Last updated: Wed, 19 Jun 2013

view this page in

Stackable::synchronized

(PECL pthreads >= 0.40)

Stackable::synchronizedSynchronisation

Description

final public mixed Stackable::synchronized ( Closure $block [, mixed $... ] )

Exécute le bloc tout en maintenant le verrou de synchronisation pour le contexte courant.

Liste de paramètres

block

Le bloc de code à exécuter.

...

Liste d'arguments variables à utiliser comme arguments de la fonction du bloc de code.

Valeurs de retour

La valeur retournée par le bloc de code.

Exemples

Exemple #1 Synchronisation

<?php
class My extends Stackable {
    public function 
run() {
        
$this->synchronized(function($object){
            
var_dump($object->isWaiting());
            
$object->notify();
        }, 
$this);
    }
}
/** Création d'un Worker **/
$my = new My();
/** On place My dans la pile **/
/** Exécution de quelque chose ici **/
$my->synchronized(function($object){
    
$object->wait();
}, 
$my);
?>

L'exemple ci-dessus va afficher :

bool(/** true ou false **/)



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

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