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, withIcicle\Concurrent\Worker\BasicEnvironment
being the default implementation provided to workers that is then provided toIcicle\Concurrent\Worker\Task::run()
. Workers with different implementations ofEnvironment
can be easily created for particular applications.Icicle\Concurrent\Worker\Queue
has been removed. The functionality of queues has been merged intoIcicle\Concurrent\Worker\Pool
through a newget()
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.