dev-master
9999999-dev https://github.com/gielfeldt/simple-workerSimple worker and pool library.
MIT
The Requires
- php >=5.4.0
by Thomas Gielfeldt
queue worker pool
Wallogit.com
2017 © Pedro Peláez
Simple worker and pool library.
To install the Simple Worker library in your project using Composer, first add the following to your composer.json
config file., (*3)
{
"require": {
"gielfeldt/simple-worker": "^0.1"
}
}
Then run Composer's install or update commands to complete installation. Please visit the Composer homepage for more information about how to use Composer., (*4)
This class allows you to queue operations in a pool and let them commence when ready., (*5)
<?php
namespace Gielfeldt\SimpleWorker\Example;
require 'vendor/autoload.php';
use Gielfeldt\SimpleWorker\Pool;
use Gielfeldt\SimpleWorker\Test\SimpleTestWorker;
$pool = new Pool(['concurrency' => 1]);
$time = microtime(true);
$workers = [];
for ($i = 0; $i < 10; $i++) {
$workers[] = new SimpleTestWorker(uniqid(), 0.5);
}
print "Adding worker\n";
$pool->addWorkers($workers, function ($worker) use ($time) {
$elapsed = microtime(true) - $time;
print "\n$worker->key is ready! Elapsed time: $elapsed\n";
});
print "Processing workers\n";
$pool->process([
'progress_callback' => function ($pool) {
print ".";
},
'finish_callback' => function ($pool) {
print "\n";
},
]);
For more examples see the examples/ folder., (*6)
Simple worker and pool library.
MIT
queue worker pool