GoLang Threaded::from

request it (60)
GoLang replacement for PHP's Threaded::from [edit | history]



Do you know a GoLang replacement for PHP's Threaded::from? Write it!

PHP Threaded::from

PHP original manual for Threaded::from [ show | php.net ]

Threaded::from

(PECL pthreads >= 2.0.9)

Threaded::fromCreation

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

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