Example #1
0
 /**
  * @param \Icicle\Loop\LibeventLoop $loop
  * @param int $eventType
  */
 public function __construct(LibeventLoop $loop, int $eventType)
 {
     $this->loop = $loop;
     $this->base = $this->loop->getEventBase();
     $this->type = $eventType;
     $this->callback = function ($resource, int $what, Io $io) {
         $this->pending[(int) $resource] = false;
         $io->call(0 !== (EV_TIMEOUT & $what));
     };
 }
Example #2
0
 /**
  * @param \Icicle\Loop\LibeventLoop $loop
  * @param \Icicle\Loop\Events\EventFactoryInterface $factory
  * @param resource $base
  */
 public function __construct(LibeventLoop $loop, EventFactoryInterface $factory)
 {
     $this->loop = $loop;
     $this->factory = $factory;
     $this->base = $this->loop->getEventBase();
     $this->callback = function ($resource, $what, SocketEventInterface $socket) {
         $this->pending[(int) $resource] = false;
         $socket->call(0 !== (EV_TIMEOUT & $what));
     };
 }
 /**
  * @param \Icicle\Loop\LibeventLoop $loop
  */
 public function __construct(LibeventLoop $loop)
 {
     $this->loop = $loop;
     $this->base = $this->loop->getEventBase();
     $this->timers = new ObjectStorage();
     $this->callback = function ($resource, $what, Timer $timer) {
         if ($timer->isPeriodic()) {
             event_add($this->timers[$timer], $timer->getInterval() * self::MICROSEC_PER_SEC);
         } else {
             event_free($this->timers[$timer]);
             unset($this->timers[$timer]);
         }
         $timer->call();
     };
 }
Example #4
0
 /**
  * @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);
 }