/** * @param ReadableStreamInterface $stream */ public function __construct(ReadableStreamInterface $stream) { $this->stream = $stream; $this->stream->on('data', array($this, 'handleData')); $this->stream->on('end', array($this, 'handleEnd')); Util::forwardEvents($this->stream, $this, ['error']); }
public function __construct(ReadableStreamInterface $readable, WritableStreamInterface $writable) { $this->readable = $readable; $this->writable = $writable; Util::forwardEvents($this->readable, $this, array('data', 'end', 'error', 'close')); Util::forwardEvents($this->writable, $this, array('drain', 'error', 'close', 'pipe')); $this->readable->on('close', array($this, 'close')); $this->writable->on('close', array($this, 'close')); $this->on('pipe', array($this, 'handlePipeEvent')); }
/** @test */ public function forwardEventsShouldSetupForwards() { $source = new ReadableStream(); $target = new ReadableStream(); Util::forwardEvents($source, $target, array(Event::DATA)); $target->on(Event::DATA, $this->expectCallableOnce()); $target->on('foo', $this->expectCallableNever()); $source->emit(Event::DATA, array('hello')); $source->emit('foo', array('bar')); }
public function __construct(ReadableStreamInterface $readable, WritableStreamInterface $writable) { $this->readable = $readable; $this->writable = $writable; Util::forwardEvents($this->readable, $this, array(Event::DATA, Event::END, Event::ERROR, Event::CLOSE)); Util::forwardEvents($this->writable, $this, array(Event::DRAIN, Event::ERROR, Event::CLOSE, Event::PIPE)); $this->readable->on(Event::CLOSE, array($this, 'close')); $this->writable->on(Event::CLOSE, array($this, 'close')); $this->on(Event::PIPE, array($this, 'handlePipeEvent')); }
/** * @param Process $process * @param LoopInterface $loop * @param array $options * @param float $interval * @return \React\Promise\PromiseInterface */ public static function parent(Process $process, LoopInterface $loop, array $options = [], $interval = self::INTERVAL) { $process->start($loop, $interval); return \WyriHaximus\React\tickingPromise($loop, $interval, [$process, 'isRunning'])->then(function () use($process, $options) { $messenger = new Messenger($process->stdin, $process->stdout, $process->stderr, ['read_err' => 'stderr', 'read' => 'stdout', 'write' => 'stdin', 'callForward' => function ($name, $arguments) use($process) { return call_user_func_array([$process, $name], $arguments); }] + $options); Util::forwardEvents($process, $messenger, ['exit']); return \React\Promise\resolve($messenger); }); }
protected function spawnProcess() { $processOptions = isset($this->options['processOptions']) ? $this->options['processOptions'] : []; $process = clone $this->sourceProcess; Factory::parent($process, $this->loop, $processOptions)->then(function (Messenger $messenger) { Util::forwardEvents($messenger, $this, ['error']); $this->pool->attach($messenger); $this->readyPool->enqueue($messenger); $this->emit('messenger', [$messenger, $this]); }, function ($error) { $this->emit('error', [$error, $this]); }); }
/** * Adapter constructor. * @param LoopInterface $loop * @param array $options */ public function __construct(LoopInterface $loop, array $options = [], FlysystemInterface $flysystem = null) { $this->loop = $loop; $this->invoker = \React\Filesystem\getInvoker($this, $options, 'invoker', 'React\\Filesystem\\InstantInvoker'); $this->openFileLimiter = new OpenFileLimiter(\React\Filesystem\getOpenFileLimit($options)); Flexible::createFromClass(Worker::class, $loop, ['min_size' => 0, 'max_size' => 50])->then(function (PoolInterface $pool) { $this->pool = $pool; }); Util::forwardEvents($this->pool, $this, ['error']); $this->pool->on('worker', function (WorkerInterface $worker) { $worker->rpc(Factory::rpc('setFlysystem', ['flysystem' => serialize($this->flysystem)])); }); $this->options = array_merge_recursive($this->options, $options); $this->flysystem = $flysystem; }
public function handlePipeEvent($source) { Util::forwardEvents($source, $this, array('error')); }
public function handlePipeEvent($source) { Util::forwardEvents($source, $this, array(Event::ERROR)); }