示例#1
0
 /**
  * Construct
  */
 public function __construct()
 {
     parent::__construct();
     $class = new \ReflectionClass('\\React\\EventLoop\\ExtEventLoop');
     $property = $class->getProperty('eventBase');
     $property->setAccessible(true);
     $this->_eventBase = $property->getValue($this);
 }
示例#2
0
 /**
  * Retry connecting to the transport
  */
 public function retryConnection()
 {
     $options = $this->reconnectOptions;
     if ($this->attemptRetry === false) {
         return;
     }
     if ($options['max_retries'] <= $this->retryAttempts) {
         return;
     }
     $this->retryAttempts++;
     if ($this->retryTimer >= $options['max_retry_delay']) {
         $this->retryTimer = $options['max_retry_delay'];
     } elseif ($this->retryTimer == 0) {
         $this->retryTimer = $options['initial_retry_delay'];
     } else {
         $this->retryTimer = $this->retryTimer * $options['retry_delay_growth'];
     }
     $this->loop->addTimer($this->retryTimer, function () {
         $this->transportProvider->startTransportProvider($this, $this->loop);
     });
 }
示例#3
0
 /**
  * Registers a periodically triggered status event.
  */
 private function registerTimedEvents()
 {
     $this->reactLoop->addPeriodicTimer($this->config->getStatusLoopInterval(), function () {
         $memoryUsageMb = memory_get_usage(true) / 1024 / 1024;
         $this->runtimeStatistics->setMemoryUsageMb($memoryUsageMb);
         if ($memoryUsageMb > $this->config->getMemoryLimitMbWarn()) {
             $this->logger->warning("MemoryUsage:   {$memoryUsageMb} MB.");
         } else {
             if ($memoryUsageMb > $this->config->getMemoryLimitMbInfo()) {
                 $this->logger->info("MemoryUsage:   {$memoryUsageMb} MB.");
             }
         }
         $memoryPeakUsageMb = memory_get_peak_usage(true) / 1024 / 1024;
         $this->runtimeStatistics->setMemoryPeakUsageMb($memoryPeakUsageMb);
         if ($memoryPeakUsageMb > $this->config->getMemoryPeakLimitMbWarn()) {
             $this->logger->warning("MemoryPeakUsage " . memory_get_peak_usage(true) / 1024 / 1024 . " MB.");
         }
         $rateObjects = $this->runtimeStatistics->getAddedObjectRate($this->config->getStatusLoopInterval());
         $rateEvictions = $this->runtimeStatistics->getEvictionRate($this->config->getStatusLoopInterval());
         $this->logger->info("Added objects: {$this->runtimeStatistics->getAddedObjectCount()}, evictions: {$this->runtimeStatistics->getEvictedObjectCount()} ({$rateObjects} Obj/Sec, {$rateEvictions} Evi/Sec).");
         $this->runtimeStatistics->tick();
     });
 }
示例#4
0
 /**
  *
  */
 public function run()
 {
     $this->reactLoop->run();
 }
示例#5
0
 /**
  *
  */
 public function stop()
 {
     $this->loop->stop();
 }
示例#6
0
 public function run()
 {
     $this->addTimer(0.1, $this->onStart);
     $this->addPeriodicTimer(0.4, $this->onLoop);
     parent::run();
 }
示例#7
0
 /**
  * @return Client
  */
 public function run() : Client
 {
     $this->loop->run();
     return $this;
 }
示例#8
0
 public function run()
 {
     $this->loop->run();
 }