Threaded::from

(PECL pthreads >= 2.0.9)

Threaded::fromCreation

Внимание

This method has been removed in pthreads v3. With the introduction of anonymous classes in PHP 7, these can now be used instead.

Описание

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

Creates an anonymous Threaded object from closures

Список параметров

run

The closure to use for ::run

construct

The constructor to use for anonymous object

args

The arguments to pass to constructor

Возвращаемые значения

A new anonymous Threaded object

Примеры

Пример #1 Thread safe objects from closures

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

Результат выполнения данного примера:

Hello World