pht\Thread::addFunctionTask
Function threading
&reftitle.description;
public voidpht\Thread::addFunctionTask
callablefunc
mixedfuncArgs
Adds a new function task to a pht\Threads internal task queue.
&reftitle.parameters;
func
The function to be threaded. If it is bound to an instance, then
$this will become &null;.
funcArgs
An optional list of arguments for the function. These arguments will be
serialised (since they are being passed to another thread).
&reftitle.returnvalues;
No return value.
&reftitle.examples;
Adding a new function task to a thread
addFunctionTask(static function($one) {var_dump($one);}, 1);
$thread->addFunctionTask(function() {var_dump(2);});
$thread->addFunctionTask('aFunc');
$thread->addFunctionTask('array_map', function ($n) {var_dump($n);}, [4]);
$thread->addFunctionTask(['Test', 'run']);
$thread->addFunctionTask([new Test, 'run2']);
$thread->start();
$thread->join();
]]>
&example.outputs;