/** * Flush the callback queue. * * Invokes callbacks which were on the queue when tick() was called and newly added ones. */ public function tick() { while (!$this->queue->isEmpty() && $this->loop->isRunning()) { $this->callback = $this->queue->dequeue(); $callback = $this->callback; // without this proxy PHPStorm marks line as fatal error. $callback($this->loop); } }
/** * @override * @inheritDoc */ public function getFlowController() { return $this->loop->getFlowController(); }
/** * @override * @inheritDoc */ public function cancel() { if (isset($this->loop)) { $this->loop->cancelTimer($this); } }
/** * @override * @inheritDoc */ public function swap(LoopModelInterface $loop, $all = false) { $this->stop(); $loop->stop(); $list = $all === true ? $this : $this->getTransferableProperties(); foreach ($list as $key => $val) { $tmp = $loop->{$key}; $loop->{$key} = $this->{$key}; $this->{$key} = $tmp; } return $this; }
/** * @dataProvider loopsProvider * @param LoopExtendedInterface|LoopModelInterface|mixed $loop */ public function testApiFlush_FlushesAllHandlers_WhenAllFlagSetToTrue($loop) { $stream = $this->createStream(); $loop->onAfterTick($this->expectCallableNever()); $loop->onBeforeTick($this->expectCallableNever()); $loop->addWriteStream($stream, $this->expectCallableNever()); $loop->addReadStream($stream, $this->expectCallableNever()); $loop->erase(true); $loop->tick(); unset($stream); unset($loop); }