amphp/parallel
True parallel processing for PHP with Amp: run blocking tasks in worker processes or threads without blocking the event loop and without extra extensions. Includes non-blocking concurrency tools and a worker pool API for submitting tasks and collecting results.
SplObjectStorage::attach by @eliashaeussler in https://github.com/amphp/parallel/pull/224Full Changelog: https://github.com/amphp/parallel/compare/v2.3.2...v2.3.3
str_increment() to fix PHP 8.5 deprecation by @nicolas-grekas in https://github.com/amphp/parallel/pull/222Full Changelog: https://github.com/amphp/parallel/compare/v2.3.1...v2.3.2
Please upgrade to 2.x if you can.
Full Changelog: https://github.com/amphp/parallel/compare/v1.4.3...v1.4.4
Full Changelog: https://github.com/amphp/parallel/compare/v2.3.0...v2.3.1
LimitedWorkerPool extending WorkerPool in https://github.com/amphp/parallel/pull/205.DelegatingWorkerPool implementing LimitedWorkerPool, which will only allow a limited number of workers to be pulled from a delegate WorkerPool instance.ContextWorkerPool also now implements LimitedWorkerPool, as this pool implementation was already spawned a limited number of workers.Full Changelog: https://github.com/amphp/parallel/compare/v2.2.9...v2.3.0
SocketIpcHub.Full Changelog: https://github.com/amphp/parallel/compare/v2.2.8...v2.2.9
Context as covariant.Full Changelog: https://github.com/amphp/parallel/compare/v2.2.6...v2.2.7
Full Changelog: https://github.com/amphp/parallel/compare/v2.2.5...v2.2.6
DefaultContextFactory was not shutdown.Full Changelog: https://github.com/amphp/parallel/compare/v2.2.4...v2.2.5
SocketIpcHub not removing the temporary socket file if the object was not explicitly closed before destruction (fixes #183).Full Changelog: https://github.com/amphp/parallel/compare/v2.2.3...v2.2.4
SocketIpcHub::accept() after cancelling a prior accept operation.Full Changelog: https://github.com/amphp/parallel/compare/v2.2.2...v2.2.3
ProcessContext created by DefaultContextFactory if output buffers fill by piping STDOUT and STDERR to the same pipes on the parent process. This also provides parity with the default behavior of ThreadContext.ContextWorkerPool.ProcessContext closing immediately after the process exited which potentially prevented reading the last sent data.Context::join() may now be called at any time instead of needing to wait until the context has sent or received all data on its channel.ContextPanicError, TaskFailureException, and TaskFailureError to avoid the backtrace being hidden from users due to PHP not calling Throwable::__toString() on previous exceptions. (#168)ContextWorkerPool. Previously, in some circumstances two tasks may have been assigned to a single worker if both were enqueued when the worker finished a prior task. (#177)ContextPanicError is no longer thrown from receive(), send(), and join() in Context. Only ContextException can now be thrown from these methods. A ContextPanicError will be wrapped instead in a ContextException.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.
Process renamed to ProcessContextParallel renamed to ThreadContextContext::isRunning() and Context::kill() replaced by Context::isClosed() and Context::close()run → startContextfactory → contextFactorycreate has been removed, use startContextProcessContext (including workers executing tasks), allowing step debugging through IDEs such as PhpStorm.ContextPanicError or TaskFailureThrowable to a string, i.e., when the exception is uncaught in the parent and is written to STDERRCancellation argument to ContextFactory::start()Pool renamed to WorkerPool and DefaultPool renamed to ContextWorkerPoolTaskWorker has been marked as internal. Use a WorkerFactory to create Worker instances or use WorkerPool::getWorker() to get a worker from a poolTaskRunner has been removedTaskException and TaskErrorWorker::enqueue() renamed to Worker::submit(), which now returns an Execution object
Execution::getFuture() returns a future that resolves to the eventual return value of the TaskExecution::await() awaits the result of the Task, it is a shortcut to calling Execution::getFuture()->await()Execution::getChannel() returns a Channel that can be used to communicate with the Channel provided to Task::run()Task::run() have changed to Channel and CancellationInter-process communication is now exposed as part of the public API for potential use outside of the context and worker components.
ContextPanicError or TaskFailureThrowable to a string, i.e., when the exception is uncaught in the parent and is written to STDERRProcessContext (including workers executing tasks), allowing step debugging through IDEs such as PhpStorm.Cancellation argument to ProcessContext::start() and ContextFactory::start()2.0 of amphp/socketUpdate for Closable interface being moved from amphp/byte-stream to amphp/amp.
Amp\Parallel\Ipc\IpcHub now extends Amp\Closable instead of Amp\ByteStream\Closable.Amp\Parallel\Process\Context gained an onClose method because Amp\Sync\Channel now extends Amp\Closable.IpcHub now extends Closable, adding an onClose() method.Initial release compatible with AMPHP v3.
All classes related to ext-pthreads and ext-parallel have been removed as both extension do not have releases on PHP 8.x.
Classes in the Amp\Parallel\Sync namespace have been moved to amphp/sync.
Process renamed to ProcessContextContext::isRunning() and Context::kill() replaced by Context::isClosed() and Context::close()run → startContextfactory → contextFactorycreate has been removed, use startContextPool renamed to WorkerPool and DefaultPool renamed to DefaultWorkerPoolTaskWorker renamed to DefaultWorkerTaskRunner has been moved to a function, runTasksTaskException and TaskErrorWorker::enqueue() renamed to Worker::submit(), which now returns an Execution object
Execution::getResult() returns a future that resolves to the eventual return value of the TaskExecution::getChannel() returns a Channel that can be used to communicate with the Channel provided to Task::run()Task::run() have changed to Channel, Cache, and CancellationFull Changelog: https://github.com/amphp/parallel/compare/v1.4.0...v1.4.1
Amp\Serialization\Serializer instance to the constructor of ChannelledStream, ChannelledSocket, and SharedMemoryParcel using the new amphp/serialization library. This new parameter allows the serialization algorithm to be customized (e.g., using JSON or allowing only strings instead of only PHP built-in serializer).Worker::isRunning() when a worker crashes. (#110)Task return value is not serializable. (#103)ContextPanicError which extends the now-deprecated PanicError. This class contains improved methods for retrieving the original class name, exception message, code, and flattened stack trace of exceptions thrown in the child process or thread.TaskFailureException and TaskFailureError, extending TaskException and TaskError respectively, which are now deprecated, to improve error reporting from workers. These classes are similar to ContextPanicError with improvements to retrieving information about the original exception.ContextFactory and functions Amp\Parallel\Context\create() and Amp\Parallel\Context\run() to create a context automatically based on installed extensions (i.e., a child process or a thread if ext-parallel is installed).BootstrapWorkerFactory which includes a user-defined file when a worker is created. This is useful for including a custom autoloader or other bootstrapping logic.WorkerProcess and WorkerThread constructors.AMP_CONTEXT constant for identifying what type of context is running and a AMP_CONTEXT_ID constant, a unique integer identifier for that context.ChannelledSocket has reference() and unreference() methods that reference and unreference the underlying socket in the event loop.Process::join(), Process::receive(), or Process::send().1.1.0 of orphaned child processes resulting from a pool instance being destroyed. Be sure to call Pool::shutdown() to end worker processes gracefully.Worker\CallableTask and Worker\enqueueCallable() function to execute serializable callables in a worker without defining a class implementing Task.Context\Process::start() now resolves to the process PID instead of null.CTRL-C immediately ends the PHP process, so workers are immediately killed. To gracefully shutdown workers or worker pools, a signal handler must be defined for SIGINT/SIGTERM to allow the PHP process to continue execution (even if that handler ends the process by stopping the event loop).How can I help you explore Laravel packages today?