1
0
mirror of https://github.com/danog/parallel.git synced 2024-11-26 20:34:40 +01:00

Add spawn shortcut for threads

This commit is contained in:
coderstephen 2015-08-21 22:39:56 -05:00
parent d94f9441ba
commit 163ffb4f54

View File

@ -28,6 +28,20 @@ class ThreadContext implements ContextInterface
*/
private $channel;
/**
* Spawns a new thread and runs it.
*
* @param callable $function A callable to invoke in the thread.
*
* @return ThreadContext The thread object that was spawned.
*/
public static function spawn(callable $function /* , ...$args */)
{
$thread = new static($function);
$thread->start();
return $thread;
}
/**
* Creates a new thread context from a thread.
*