Threaded
PHP Manual

Threaded::from

(PECL pthreads >= 2.0.9)

Threaded::fromCreation

Descrierea

public Threaded Threaded::from ( Closure $run [, Closure $construct [, array $args ]] )

Creates an anonymous Threaded object from closures

Parametri

run

The closure to use for ::run

construct

The constructor to use for anonymous object

args

The arguments to pass to constructor

Valorile întoarse

A new anonymous Threaded object

Exemple

Example #1 Thread safe objects from closures

<?php
$pool 
= new Pool(4);
$pool->submit(Collectable::from(function(){
    echo 
"Hello World";
    
$this->setGarbage();
}));
/* ... */
$pool->shutdown();
?>

Exemplul de mai sus va afișa:

Hello World


Threaded
PHP Manual