Update README.md, consistent use of spaces instead of tabs, better examples
This commit is contained in:
21
bin/single_worker_with_job_class.php
Normal file
21
bin/single_worker_with_job_class.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Toalett\Multiprocessing\Concurrency;
|
||||
use Toalett\Multiprocessing\ContextBuilder;
|
||||
use Toalett\Multiprocessing\Task\Interval;
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
require_once __DIR__ . '/classes/Job.php';
|
||||
|
||||
$context = ContextBuilder::create()
|
||||
->withConcurrency(Concurrency::singleWorker())
|
||||
->withCleanupInterval(Interval::seconds(0.2))
|
||||
->build();
|
||||
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$title = md5(mt_rand());
|
||||
$context->submit(new Job($title));
|
||||
}
|
||||
|
||||
$context->on('no_workers_remaining', [$context, 'stop']);
|
||||
$context->run();
|
||||
Reference in New Issue
Block a user