/** * @param ProcessCollectionInterface $processCollection * @param LoopInterface $loop * @param array $options */ public function __construct(ProcessCollectionInterface $processCollection, LoopInterface $loop, array $options = []) { $this->loop = $loop; $this->options = $options; $this->queue = \WyriHaximus\React\ChildProcess\Pool\getQueue($this->options, 'WyriHaximus\\React\\ChildProcess\\Pool\\Queue\\Memory', $loop); $this->manager = \WyriHaximus\React\ChildProcess\Pool\getManager($this->options, $processCollection, 'WyriHaximus\\React\\ChildProcess\\Pool\\Manager\\Fixed', $loop); $this->manager->on('ready', function (WorkerInterface $worker) { $this->emit('worker', [$worker]); if ($this->queue->count() === 0) { return; } \React\Promise\resolve($this->queue->dequeue())->then(function (Rpc $message) use($worker) { $hash = spl_object_hash($message); $this->deferreds[$hash]->resolve($worker->rpc($message)); unset($this->deferreds[$hash]); }); }); }
/** * @dataProvider providerGetQueue */ public function testGetQueue($options, $default, $loop, $output) { $this->assertEquals($output, \WyriHaximus\React\ChildProcess\Pool\getQueue($options, $default, $loop)); }