parallel\Runtime::run

(0.8.0)

parallel\Runtime::runParallel Execution

说明

public parallel\Runtime::run ( Closure $closure ) : ?Future

Shall schedule closure for execution in parallel.

public parallel\Runtime::run ( Closure $closure , array $args ) : ?Future

Shall schedule closure for execution in parallel, passing args at execution time.

参数

closure

A Closure with specific characteristics.

args

An array of arguments with specific characteristics to be passed to closure at execution time.

Closure Characteristics

Closures scheduled for parallel execution must not:

  • accept or return by reference
  • accept or return objects
  • execute a limited set of instructions

Instructions prohibited in Closures scheduled for parallel execution are:

  • declare (anonymous) function
  • declare (anonymous) class
  • lexical scope access
  • yield

Note:

No instructions are prohibited in the files which the Closure may include.

Arguments Characteristics

Arguments must not:

  • contain references
  • contain objects
  • contain resources

Note:

In the case of file stream resources, the resource will be cast to the file descriptor and passed as int where possible, this is unsupported on Windows.

返回值

Warning

A \parallel\Future shall only be returned if closure contains a return statement.

Exceptions

Warning

Shall throw \parallel\Exception if \parallel\Runtime was closed.

Warning

Shall throw \parallel\Exception if closure does not have the required characteristics.

Warning

Shall throw \parallel\Exception if args does not have the required characteristics.

Warning

Shall throw \parallel\Exception if \parallel\Future is ignored by caller.