Open
Description
According to the example:
$pool = new \Jenner\SimpleFork\FixedPool(2);
$pool->execute(new \Jenner\SimpleFork\Process(new TestRunnable()));
$pool->execute(new \Jenner\SimpleFork\Process(new TestRunnable()));
$pool->execute(new \Jenner\SimpleFork\Process(new TestRunnable()));
$pool->wait();
Code:
use \Jenner\SimpleFork\Pool;
use \Jenner\SimpleFork\FixedPool;
use \Jenner\SimpleFork\ParallelPool;
use \Jenner\SimpleFork\Process;
use \Jenner\SimpleFork\Runnable;
class TestRunnable implements Runnable
{
private $id = 0;
public function __construct($id) {
$this->id = $id;
}
public function run()
{
echo "[".$this->id."]\n";
sleep(1);
}
}
$pool = new FixedPool(2);
$pool->execute(new Process(new TestRunnable(1)));
$pool->execute(new Process(new TestRunnable(2)));
$pool->execute(new Process(new TestRunnable(3)));
$pool->wait();
Result:
PHP Fatal error: Uncaught RuntimeException: you should extend the `\Jenner\SimpleFork\Process` and overwrite the run method in /var/www/site/www/core/vendor/jenner/simple_fork/src/Utils.php:31
Stack trace:
#0 /var/www/site/www/core/vendor/jenner/simple_fork/src/FixedPool.php(34): Jenner\SimpleFork\Utils::checkOverwriteRunMethod('Jenner\\SimpleFo...')
#1 /var/workspace/test_curl.php(31): Jenner\SimpleFork\FixedPool->execute(Object(Jenner\SimpleFork\Process))
#2 {main}
thrown in /var/www/site/www/core/vendor/jenner/simple_fork/src/Utils.php on line 31
Metadata
Metadata
Assignees
Labels
No labels