@trowski trowski released this Oct 27, 2018 · 12 commits to master since this release

Assets 2

IPC has been greatly improved in this release. STDIN and STDOUT were previously used for process communication, redirecting child process output to STDERR. However, this was often problematic for debugging and caused to confusion. Processes now used a dedicated socket for IPC, leaving the standard I/O streams available for for the user. These streams can be accessed on Context\Process using getStdin(), getStdout(), and getStderr(). No automatic forwarding of child output is done for Context\Process. Worker\WorkerProcess now automatically forwards STDOUT and STDERR to the parent STDOUT and STDERR. Using echo, print, printf(), etc. in Worker\Task::run() is still not recommended as ordering is not guaranteed and interleaving is very possible. However, for debugging purposes these functions can be useful.

Users of this library that only used the Worker\Worker or Worker\Pool interfaces are unlikely to need to make any changes to their code to upgrade from 0.2.x. Most other BC breaks are minor.

  • STDOUT of the process run using Context\Process is no longer redirected to STDERR of the parent process. STDIN, STDOUT, and STDERR of the child process are now available as stream objects using getStdin(), getStdout(), and getStderr().
  • AbstractWorker has been renamed to TaskWorker. The protected method cancel() was removed.
  • Subsequent calls to Worker::shutdown() now return the same promise as the first call. Prior, subsequent calls would throw an exception.
  • Context\Context::start() now returns a promise that is resolved once the context starts (or fails to start).
  • Context\Process::run() now returns a promise resolving to the instance of Context\Process created.
  • Context\Thread::run() now returns a promise resolving to the instance of Context\Thread created.
  • Context\Thread::supported() has been renamed to Context\Thread::isSupported().
  • Most classes in this library are now marked as final. (Composition over inheritance!)
  • Error messages when tasks return unserializable data have been improved.
  • Custom exception constructors skipping the code argument have been dropped in favor of using the standard constructor.
  • Worker\Environment::exists() now declares bool as a return type (implementations should have always returned a bool, but is now declared in the interface).
  • Worker\Pool::get() has been renamed to Worker\Pool::getWorker().
  • The function Worker\get() has been renamed to Worker\worker().