<commit_before>## php-forked-processing (forker)
Asynchronous processing in PHP via process forking

## Example
The below is a farcical example of creating and asynchronously processing a job between 5 forked "child" processes for a total run time of 600 seconds as specified. Should a "child" process die, fail, or be completed before the 600 seconds, a new "child" process will be immediately spun up in it's place. Feel free to run this example and watch the terminal output while killing off and letting "child" processes finish their job.

```php
<?php
declare(ticks=1);

require_once 'vendor/autoload.php';

use ryancco\forker\JobInterface;
use ryancco\forker\WorkerDaemon;

class TestJob implements JobInterface
{
    public function __invoke()
    {
        echo "New child spawned! [PID " . getmypid() . "]\n";
        for ($i = 1; $i <= 5; $i++) {
            echo $this->formatOutput($i);
            sleep(10);
        }
    }

    private function formatOutput($loops)
    {
        return "Pass #" . $loops . " [PID " . getmypid() . "]\n";
    }

    public function __destruct()
    {
        echo "__destruct() [PID " . getmypid() . "]\n";
    }
}

$wd = new WorkerDaemon(5, 300);
$wd->executeJob(new TestJob());
```

## License<commit_msg>Updated README with more concise example implementation<commit_after>## php-forked-processing (forker)
Asynchronous processing in PHP via process forking

## Example
The below is a farcical example of creating and asynchronously processing a job between 5 forked "child" processes for a total run time of 300 seconds as specified. Should a "child" process die, fail, or be completed before the specified time, a new "child" process will be immediately spun up in it's place. Feel free to run this example and watch the terminal output while killing off and letting "child" processes finish their job.

```php
<?php

require_once 'vendor/autoload.php';

use ryancco\forker\JobInterface;
use ryancco\forker\WorkerDaemon;

declare(ticks=1); // PHP <= 5.6.*

class TestJob implements JobInterface
{
    // Entry point for each child worker
    public function __invoke()
    {
        echo "New child spawned! [PID " . getmypid() . "]\n";
        $this->countTo(5);
    }
    
    public function countTo($max = 5)
    {
        for ($i = 1; $i <= $max; $i++) {
            echo $this->formatOutput($i);
            sleep(10);
        }
    }

    private function formatOutput($loops)
    {
        return "Pass #" . $loops . " [PID " . getmypid() . "]\n";
    }

    // Will be executed on every graceful exit
    public function __destruct()
    {
        echo "__destruct() [PID " . getmypid() . "]\n";
    }
}

$wd = new WorkerDaemon(5, 300);
$wd->executeJob(new TestJob());
```

## License
{'fraction_non_alphanumeric': 0.11721878412813978, 'fraction_numerical': 0.011649071714597743, 'mean_word_length': 3.0352422907488985, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1579502', 'n_tokens_mistral': 881, 'n_tokens_neox': 810, 'n_words': 307}