PHP code example of travail / parallel-prefork

1. Go to this page and download the library: Download travail/parallel-prefork 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/ */

    

travail / parallel-prefork example snippets



use \Parallel\Prefork;

_workers'  => 5,
    'trap_signals' => [
        SIGHUP  => SIGTERM,
        SIGTERM => SIGTERM,
    ],
]);

while ($pp->signalReceived() !== SIGTERM) {
    if ($pp->start()) {
        continue;
    }

    // ... do some work within the child process ...

    $pp->finish();
}

$pp->waitAllChildren();

Parallel\Prefork __construct([
    'max_workers'          => int $max_workers,
    'err_respawn_interval' => int $err_respawn_interval,
    'trap_signals'         => [int $signal_trapped_in_parent_process => int $signal_sent_to_child_processes],
])

bool start()

void finish(int $exit_code)

void signalAllChildren(int $signal)

void waitAllChildren()

int signalReceived()