/**
  * @param string $name
  *
  * @return bool
  */
 public function isPeriodicTimerActive($name)
 {
     $tid = $this->getTid($name);
     if (!isset($this->registry[$tid])) {
         return false;
     }
     return $this->loop->isTimerActive($this->registry[$tid]);
 }
 /**
  * @param TopicInterface $topic
  * @param string         $name
  *
  * @return bool
  */
 public function isPeriodicTimerActive(TopicInterface $topic, $name)
 {
     $namespace = spl_object_hash($topic);
     if (!isset($this->registry[$namespace][$name])) {
         return false;
     }
     return $this->loop->isTimerActive($this->registry[$namespace][$name]);
 }
 /**
  * @param Rpc $message
  * @return PromiseInterface
  */
 protected function queueRpc(Rpc $message)
 {
     $deferred = new Deferred();
     $this->callQueue->enqueue($deferred);
     if ($this->timer === null || !$this->loop->isTimerActive($this->timer)) {
         $this->timer = $this->loop->addTimer(static::INTERVAL, function () {
             $this->checkQueue();
         });
     }
     return $deferred->promise()->then(function () use($message) {
         return $this->sendRpc($message);
     });
 }
 /**
  *
  */
 protected function onEnd()
 {
     if ($this->requestTimer !== null && $this->loop->isTimerActive($this->requestTimer)) {
         $this->loop->cancelTimer($this->requestTimer);
     }
     if ($this->connectionTimer !== null && $this->loop->isTimerActive($this->connectionTimer)) {
         $this->loop->cancelTimer($this->connectionTimer);
     }
     $this->loop->futureTick(function () {
         if ($this->httpResponse === null) {
             $this->deferred->reject($this->error);
         }
     });
 }
 /**
  * @param Server        $server
  * @param LoopInterface $loop
  */
 protected function closure(Server $server, LoopInterface $loop)
 {
     $this->logger->notice('Stopping server ...');
     foreach ($this->serverPushHandlerRegistry->getPushers() as $handler) {
         $handler->close();
         $this->logger->info(sprintf('Stop %s push handler', $handler->getName()));
     }
     $server->emit('end');
     $server->shutdown();
     foreach ($this->periodicRegistry->getPeriodics() as $periodic) {
         if ($periodic instanceof TimerInterface && $loop->isTimerActive($periodic)) {
             $loop->cancelTimer($periodic);
         }
     }
     $loop->stop();
     $this->logger->notice('Server stopped !');
 }
 /**
  * Check if a given timer is active.
  *
  * @param TimerInterface $timer The timer to check.
  *
  * @return boolean True if the timer is still enqueued for execution.
  */
 public function isTimerActive(TimerInterface $timer)
 {
     return $this->loop->isTimerActive($timer);
 }