Skip to content

v0.3.0

Latest
Compare
Choose a tag to compare
@trowski trowski released this 15 Jan 19:10
· 29 commits to master since this release

Added

  • Added Icicle\Concurrent\Worker\factory() function that accesses or sets the global worker factory.
  • Added Icicle\Concurrent\Worker\get() function that returns a worker from the global worker pool.

Changed

  • Icicle\Concurrent\Worker\Environment is now an interface, with Icicle\Concurrent\Worker\BasicEnvironment being the default implementation provided to workers that is then provided to Icicle\Concurrent\Worker\Task::run(). Workers with different implementations of Environment can be easily created for particular applications.
  • Icicle\Concurrent\Worker\Queue has been removed. The functionality of queues has been merged into Icicle\Concurrent\Worker\Pool through a new get() method that returns a worker from the pool. The returned worker is marked as busy until all references have been destroyed. See the example code below.
use Icicle\Concurrent\Worker\DefaultPool;

$pool = new DefaultPool();
$pool->start();
$worker = $pool->get(); // Marks $worker as busy in the pool.

// Use $worker for a series of tasks.

$worker = null; // Marks worker as idle in the pool.