Amp\Parallel\Context\Thread classThread implementsAmp\Parallel\Context\Context

Implements an execution context using native multi-threading.

The thread context is not itself threaded. A local instance of the context is maintained both in the context that creates the thread and in the thread itself.

Summary

Properties

Methods

Properties

Methods

supported —public functionsupported():bool

Checks if threading is enabled.

run —public functionrun(callable$function,mixed...$args):Amp\Parallel\Context\Thread

Creates and starts a new thread.

Type Parameter Description Default Value
callable $function The callable to invoke in the thread. First argument is an instance of \Amp\Parallel\Sync\Channel. none
mixed ... $args Additional arguments to pass to the given callable. none
__construct —public function__construct(callable$function,mixed...$args)

Creates a new thread.

Type Parameter Description Default Value
callable $function The callable to invoke in the thread. First argument is an instance of \Amp\Parallel\Sync\Channel. none
mixed ... $args Additional arguments to pass to the given callable. none
__clone —public function__clone()

Returns the thread to the condition before starting. The new thread can be started and run independently of the first thread.

__destruct —public function__destruct()

Kills the thread if it is still running.

isRunning —public functionisRunning():bool

Checks if the context is running.

start —public functionstart()

Spawns the thread and begins the thread's execution.

kill —public functionkill()

Immediately kills the context.

join —public functionjoin():Amp\Promise
No documentation.
receive —public functionreceive():Amp\Promise
No documentation.
send —public functionsend($data):Amp\Promise
No documentation.
Type Parameter Description Default Value
mixed $data No documentation. none