当前位置: 首页>>代码示例>>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;未经允许,请勿转载。