Skip to content

0.2.0

Compare
Choose a tag to compare
@trowski trowski released this 14 Dec 17:43
· 423 commits to 2.x since this release
c545be1

(Note all class and interface names below are relative to Amp\Parallel)

  • The forking context has been completely removed. Forking the entire process state proved to be too error-prone to be useful as a general-purpose parallel execution context.
  • Sync\Mutex and Sync\Semaphore interfaces and related classes have been moved to amphp/sync.
  • Thread and process contexts are now found in the Context namespace. Process\ChannelledProcess renamed to Context\Process and Threading\Thread renamed to Context\Thread. The interface Context has also been moved into the Context namespace, along with related exception classes, ContextException and StatusError.
  • Removed the Strand interface. Context\Context now extends Sync\Channel.
  • The process context now accepts a path to a PHP script returning a callable function. This function may return a serializable value, a promise or generator (run as a coroutine) that resolves to a serializable value. An instance of Sync\Channel is given as the only function parameter. $argc and $argv are also available as usual in CLI PHP scripts.
// process.php
use Amp\Parallel\Sync\Channel;
return function (Channel $channel) use ($argc, $argv) {
    // Code executed in child process.
    return $result;
};
  • Threading\Thread::spawn() renamed to Context\Thread::run().
  • Threading\Paracel renamed to Sync\ThreadedParcel.
  • PanicError renamed to Sync\PanicError.
  • Worker\Worker::start() removed. It is no longer necessary to manually start a worker or pool, the underlying context will automatically be started once a task is enqueued.
  • Removed Worker\Pool::getMinSize()and the $minSize parameter from Worker\DefaultPool::__construct().
  • When using an SAPI other than CLI, Context\Process will automatically search PATH for an executable named php. Alternatively, a path to the PHP binary executable may be specified by setting an environment variable or constant named AMP_PHP_BINARY.