PHP code example of netlogix / jobqueue-polling

1. Go to this page and download the library: Download netlogix/jobqueue-polling library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

netlogix / jobqueue-polling example snippets


use Netlogix\JobQueue\Polling\PollScheduler;

$scheduler = PollScheduler::create(
    loop: $loop,                              // React\EventLoop\LoopInterface
    tryToPickUpWork: fn () => $this->pickUp($pool),   // picks up as much work as capacity allows
    hasCapacity: fn () => count($pool) < $parallel,   // cheap, side-effect free
    interval: 0.1,                            // baseline poll interval in seconds
);

$scheduler->start();                          // register the periodic baseline poll

// ... when a job finishes (e.g. in the process EXIT/SUCCESS/ERROR handler):
$scheduler->requestImmediatePoll();           // pick up the next job without waiting for the interval

// ... during a drain/shutdown phase:
$scheduler->stop();                           // cancel the baseline poll (does not stop the loop)