首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Threaded::from

(PECL pthreads >= 2.0.9)

Threaded::from — Creation

Warning

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

Description

代码语言:javascript
复制
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

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

The above example will output:

代码语言:javascript
复制
Hello World

← Threaded::extend

Threaded::getTerminationInfo →

代码语言:txt
复制
 ? 1997–2017 The PHP Documentation Group

Licensed under the Creative Commons Attribution License v3.0 or later.

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com