/** * Construct */ public function __construct() { parent::__construct(); $class = new \ReflectionClass('\\React\\EventLoop\\ExtEventLoop'); $property = $class->getProperty('eventBase'); $property->setAccessible(true); $this->_eventBase = $property->getValue($this); }
/** * 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); }); }
/** * 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(); }); }
/** * */ public function run() { $this->reactLoop->run(); }
/** * */ public function stop() { $this->loop->stop(); }
public function run() { $this->addTimer(0.1, $this->onStart); $this->addPeriodicTimer(0.4, $this->onLoop); parent::run(); }
/** * @return Client */ public function run() : Client { $this->loop->run(); return $this; }
public function run() { $this->loop->run(); }