/** * @param \Icicle\Loop\EvLoop $loop * @param \Icicle\Loop\Events\EventFactoryInterface $factory */ public function __construct(EvLoop $loop, EventFactoryInterface $factory) { $this->factory = $factory; $this->loop = $loop->getEvLoop(); $this->timers = new ObjectStorage(); $this->callback = function (\EvTimer $event) { /** @var \Icicle\Loop\Events\TimerInterface $timer */ $timer = $event->data; if (!$timer->isPeriodic()) { $event->stop(); unset($this->timers[$timer]); } else { $event->again(); } $timer->call(); }; }
/** * @param bool $enableSignals True to enable signal handling, false to disable. * * @return \Icicle\Loop\LoopInterface * * @codeCoverageIgnore */ function create(bool $enableSignals = true) : LoopInterface { if (EvLoop::enabled()) { return new EvLoop($enableSignals); } if (EventLoop::enabled()) { return new EventLoop($enableSignals); } if (LibeventLoop::enabled()) { return new LibeventLoop($enableSignals); } return new SelectLoop($enableSignals); }
/** * @param \Icicle\Loop\EvLoop $loop * @param \Icicle\Loop\Events\EventFactoryInterface $factory * @param int $eventType */ public function __construct(EvLoop $loop, EventFactoryInterface $factory, int $eventType) { $this->factory = $factory; $this->loop = $loop->getEvLoop(); $this->type = $eventType; $this->socketCallback = function (\EvIO $event) { /** @var \Icicle\Loop\Events\SocketEventInterface $socket */ $socket = $event->data; $id = (int) $socket->getResource(); $event->stop(); if (isset($this->timers[$id])) { $this->timers[$id]->stop(); } $socket->call(false); }; $this->timerCallback = function (\EvTimer $event) { /** @var \Icicle\Loop\Events\SocketEventInterface $socket */ $socket = $event->data; $id = (int) $socket->getResource(); $event->stop(); $this->events[$id]->stop(); $socket->call(true); }; }
/** * Calls loopFork() on the EvLoop object. */ public function reInit() { $this->loop->loopFork(); }