mirror of
https://github.com/danog/parallel.git
synced 2025-01-22 14:01:14 +01:00
Kill worker forks
Forking for workers is just not a good idea… it's too likely to be used irresponsibly.
This commit is contained in:
parent
7f592265d0
commit
0236fc5336
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Amp\Parallel\Worker;
|
||||
|
||||
use Amp\Promise;
|
||||
use Amp\Parallel\Forking\Fork;
|
||||
use Amp\Parallel\Worker\Internal\TaskRunner;
|
||||
|
||||
/**
|
||||
* A worker thread that executes task objects.
|
||||
*/
|
||||
class WorkerFork extends AbstractWorker {
|
||||
public function __construct() {
|
||||
parent::__construct(new Fork(function (): Promise {
|
||||
$runner = new TaskRunner($this, new BasicEnvironment);
|
||||
return $runner->run();
|
||||
}));
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Amp\Parallel\Test\Worker;
|
||||
|
||||
use Amp\Parallel\Worker\{ DefaultPool, WorkerFactory, WorkerFork };
|
||||
|
||||
/**
|
||||
* @group forking
|
||||
* @requires extension pcntl
|
||||
*/
|
||||
class ForkPoolTest extends AbstractPoolTest {
|
||||
protected function createPool($min = null, $max = null) {
|
||||
$factory = $this->createMock(WorkerFactory::class);
|
||||
$factory->method('create')->will($this->returnCallback(function () {
|
||||
return new WorkerFork;
|
||||
}));
|
||||
|
||||
return new DefaultPool($min, $max, $factory);
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Amp\Parallel\Test\Worker;
|
||||
|
||||
use Amp\Parallel\Worker\WorkerFork;
|
||||
|
||||
/**
|
||||
* @group forking
|
||||
* @requires extension pcntl
|
||||
*/
|
||||
class WorkerForkTest extends AbstractWorkerTest {
|
||||
protected function createWorker() {
|
||||
return new WorkerFork;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user