當前位置: 首頁>>代碼示例>>PHP>>正文


PHP LoopInterface::nextTick方法代碼示例

本文整理匯總了PHP中React\EventLoop\LoopInterface::nextTick方法的典型用法代碼示例。如果您正苦於以下問題:PHP LoopInterface::nextTick方法的具體用法?PHP LoopInterface::nextTick怎麽用?PHP LoopInterface::nextTick使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在React\EventLoop\LoopInterface的用法示例。


在下文中一共展示了LoopInterface::nextTick方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $app = new Container();
     $app->instance('config', new Repository());
     (new EventServiceProvider($app))->register();
     (new AmiServiceProvider($app))->register();
     $this->loop = $app[LoopInterface::class];
     $this->loop->nextTick(function () {
         if (!$this->running) {
             $this->loop->stop();
         }
     });
     $this->stream = $app[Stream::class];
     $this->events = $app['events'];
     $this->app = $app;
 }
開發者ID:enniel,項目名稱:ami,代碼行數:19,代碼來源:TestCase.php

示例2: testMapEndWithPendingItems

 public function testMapEndWithPendingItems()
 {
     $map = map(function ($n, callable $callback) {
         $this->eventLoop->nextTick(function () use($callback, $n) {
             $callback(null, 2 * $n);
         });
     }, ['concurrency' => 5]);
     $items = [];
     $ended = false;
     $map->on('data', function ($n) use(&$items) {
         $items[] = $n;
     });
     $map->on('end', function () use(&$ended) {
         $ended = true;
     });
     for ($i = 0; $i < 10; $i++) {
         $map->write($i);
     }
     $map->end();
     $this->assertFalse($ended);
     $this->assertEmpty($items);
     $this->eventLoop->tick();
     $this->assertTrue($ended);
     $this->assertSame(range(0, 18, 2), $items);
 }
開發者ID:joshdifabio,項目名稱:object-stream,代碼行數:25,代碼來源:FunctionsTest.php

示例3: run

 /**
  * Start the event reactor and assume program flow control
  *
  * @param callable $onStart Optional callback to invoke immediately upon reactor start
  */
 public function run(callable $onStart = null)
 {
     if ($onStart) {
         $this->reactor->nextTick($onStart);
     }
     $this->reactor->run();
 }
開發者ID:daverandom,項目名稱:loopio,代碼行數:12,代碼來源:Loop.php

示例4: nextTick

 /**
  * Schedule a callback to be invoked on the next tick of the event loop.
  *
  * Callbacks are guaranteed to be executed in the order they are enqueued,
  * before any timer or stream events.
  *
  * @param callable $listener The callback to invoke.
  */
 public function nextTick(callable $listener)
 {
     $this->emit('nextTick', [$listener]);
     return $this->loop->nextTick(function (LoopInterface $loop) use($listener) {
         $this->emit('nextTickTick', [$listener]);
         $listener($this);
     });
 }
開發者ID:WyriHaximus,項目名稱:reactphp-event-loop-inspector,代碼行數:16,代碼來源:LoopDecorator.php

示例5: testFutureTickEventGeneratedByNextTick

 public function testFutureTickEventGeneratedByNextTick()
 {
     $stream = $this->createStream();
     $this->loop->nextTick(function () {
         $this->loop->futureTick(function () {
             echo 'future-tick' . PHP_EOL;
         });
     });
     $this->expectOutputString('future-tick' . PHP_EOL);
     $this->loop->run();
 }
開發者ID:smileytechguy,項目名稱:nLine,代碼行數:11,代碼來源:AbstractLoopTest.php

示例6: continueFlow

 /**
  * Continues the given flow.
  *
  * @param ReactFlow $flow
  * @param Packet    $packet
  */
 private function continueFlow(ReactFlow $flow, Packet $packet)
 {
     try {
         $response = $flow->next($packet);
     } catch (\Exception $e) {
         $this->emitError($e);
         return;
     }
     if ($response !== null) {
         if ($this->stream->getBuffer()->listening) {
             $this->sendingFlows[] = $flow;
         } else {
             $this->stream->write($response);
             $this->writtenFlow = $flow;
         }
     } elseif ($flow->isFinished()) {
         $this->loop->nextTick(function () use($flow) {
             $this->finishFlow($flow);
         });
     }
 }
開發者ID:binsoul,項目名稱:net-mqtt-client-react,代碼行數:27,代碼來源:ReactMqttClient.php

示例7: computeId

 /**
  * @return \React\Promise\Promise|PromiseInterface
  */
 public function computeId()
 {
     $deferred = new Deferred();
     $this->loop->nextTick($this->doCompute($deferred));
     return $deferred->promise();
 }
開發者ID:vantt,項目名稱:short-flake,代碼行數:9,代碼來源:IdGenerator.php


注:本文中的React\EventLoop\LoopInterface::nextTick方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。