Threaded::from

Threaded::from

(PECL pthreads >= 2.0.9)

Threaded::fromCreation

Warning

This method has been removed in pthreads v3.

Description

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

Creates an anonymous Threaded object from closures

Parameters

run

The closure to use for ::run

construct

The constructor to use for anonymous object

args

The arguments to pass to constructor

Return Values

A new anonymous Threaded object

Examples

Example #1 Thread safe objects from closures

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

The above example will output:

Hello World

© 1997–2017 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://secure.php.net/manual/en/threaded.from.php

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部