2.0.0
Stable release compatible with AMPHP v3 and fibers! 🎉
As with other libraries compatible with AMPHP v3, most cases of parameters or returns of Promise<ResolutionType>
have been replaced with ResolutionType
.
All classes related to ext-pthreads
have been removed as this extension does not have releases on PHP 8.x.
Classes in the Amp\Parallel\Sync
namespace have been moved to amphp/sync
.
Context
Process
renamed toProcessContext
Parallel
renamed toThreadContext
Context::isRunning()
andContext::kill()
replaced byContext::isClosed()
andContext::close()
- Context related functions:
run
→startContext
factory
→contextFactory
create
has been removed, usestartContext
- Xdebug ini settings are forwarded to processes created by
ProcessContext
(including workers executing tasks), allowing step debugging through IDEs such as PhpStorm. - Improved UX of uncaught exceptions in child processes and task runs. The full stack trace in the context is displayed when converting the
ContextPanicError
orTaskFailureThrowable
to a string, i.e., when the exception is uncaught in the parent and is written to STDERR - Added an optional
Cancellation
argument toContextFactory::start()
Worker
Pool
renamed toWorkerPool
andDefaultPool
renamed toContextWorkerPool
TaskWorker
has been marked as internal. Use aWorkerFactory
to createWorker
instances or useWorkerPool::getWorker()
to get a worker from a poolTaskRunner
has been removed- Removed deprecated
TaskException
andTaskError
Worker::enqueue()
renamed toWorker::submit()
, which now returns anExecution
objectExecution::getFuture()
returns a future that resolves to the eventual return value of theTask
Execution::await()
awaits the result of theTask
, it is a shortcut to callingExecution::getFuture()->await()
Execution::getChannel()
returns aChannel
that can be used to communicate with theChannel
provided toTask::run()
- The arguments to
Task::run()
have changed toChannel
andCancellation
IpcHub
Inter-process communication is now exposed as part of the public API for potential use outside of the context and worker components.