« parallel\run
parallel\Runtime::__construct »

The parallel\Runtime class

(0.8.0)

Runtime Objects

Each runtime represents a single PHP thread, the thread is created (and bootstrapped) upon construction. The thread then waits for tasks to be scheduled: Scheduled tasks will be executed FIFO and then the thread will resume waiting until more tasks are scheduled, or it's closed, killed, or destroyed by the normal scoping rules of PHP objects.

警告

When a runtime is destroyed by the normal scoping rules of PHP objects, it will first execute all of the tasks that were scheduled, and block while doing so.

Runtime Bootstrapping

When a new runtime is created, it does not share code with the thread (or process) that created it. This means it doesn't have the same classes and functions loaded, nor the same autoloader set. In some cases, a very lightweight runtime is desirable because the tasks that will be scheduled do not need access to the code in the parent thread. In those cases where the tasks do need to access the same code, it is enough to set an autoloader as the bootstrap.

注意:

preloading may be used in conjunction with parallel, in this case preloaded code is available without bootstrapping

クラス概要

final class parallel\Runtime {
/* Create */
public function __construct()
public function __construct(string $bootstrap)
/* Execute */
public function run(Closure $task): ?Future
public function run(Closure $task, array $argv): ?Future
/* Join */
public function close(): void
public function kill(): void
}

目次

関連キーワード:
Runtime   parallel   thread   tasks   construct   runtime   scheduled   code   created   Join   destroyed   scoping   rules   objects   autoloader   cases   need   access   bootstrap   Closure   task   Future   kill   Objects   represents
関連する関数・ページ:
parallel-runtime.construct   parallel-runtime.kill   parallel-runtime.close   parallel.bootstrap   parallel.run   parallel-runtime.run