Esempio n. 1
0
 protected function processQueue()
 {
     $this->loop->futureTick(function () {
         if ($this->callQueue->isEmpty()) {
             return;
         }
         $message = $this->callQueue->dequeue();
         $data = ['function' => $message->getFunction(), 'args' => $message->getArgs(), 'errorResultCode' => $message->getErrorResultCode()];
         $message->getDeferred()->resolve($data);
     });
 }
Esempio n. 2
0
 private function startUpdates()
 {
     if (!$this->updateQueue->isEmpty()) {
         $this->updating = true;
         $this->loop->futureTick([$this, 'update']);
     }
 }
 /**
  * Schedule a callback to be invoked on a future tick of the event loop.
  *
  * Callbacks are guaranteed to be executed in the order they are enqueued.
  *
  * @param callable $listener The callback to invoke.
  */
 public function futureTick(callable $listener)
 {
     $this->emit('futureTick', [$listener]);
     return $this->loop->futureTick(function (LoopInterface $loop) use($listener) {
         $this->emit('futureTickTick', [$listener]);
         $listener($this);
     });
 }
Esempio n. 4
0
 /**
  * @param string $function
  * @param array $args
  * @param int $errorResultCode
  * @return \React\Promise\Promise
  */
 public function callFilesystem($function, $args, $errorResultCode = -1)
 {
     $deferred = new Deferred();
     // Run this in a future tick to make sure all EIO calls are run within the loop
     $this->loop->futureTick(function () use($function, $args, $errorResultCode, $deferred) {
         $this->executeDelayedCall($function, $args, $errorResultCode, $deferred);
     });
     return $deferred->promise();
 }
Esempio n. 5
0
 public function testFutureTickEventGeneratedByTimer()
 {
     $this->loop->addTimer(0.001, function () {
         $this->loop->futureTick(function () {
             echo 'future-tick' . PHP_EOL;
         });
     });
     $this->expectOutputString('future-tick' . PHP_EOL);
     $this->loop->run();
 }
Esempio n. 6
0
 /**
  * @param Deferred $deferred
  *
  * @return \Closure
  */
 private function doCompute(Deferred $deferred)
 {
     $fnc = function () use($deferred) {
         // if we still have enough id in this epoc, compute it
         if ($this->incremental < 4096) {
             $deferred->resolve($this->current_epoc << 22 | $this->generator_id << 12 | $this->incremental++);
         } else {
             $this->loop->futureTick($this->doCompute($deferred));
         }
     };
     $fnc->bindTo($this);
     return $fnc;
 }
 protected function queueTick()
 {
     $this->loop->futureTick([$this, 'tick']);
 }
 protected function deregisterRpc()
 {
     $this->loop->futureTick(function () {
         $this->messenger->deregisterRpc(MessengerFactory::PROCESS_REGISTER);
     });
 }
 protected function resolveResponse($response)
 {
     $this->loop->futureTick(function () use($response) {
         $this->deferred->resolve($response);
     });
 }