当前位置: 首页>>代码示例>>PHP>>正文


PHP LoopInterface::tick方法代码示例

本文整理汇总了PHP中React\EventLoop\LoopInterface::tick方法的典型用法代码示例。如果您正苦于以下问题:PHP LoopInterface::tick方法的具体用法?PHP LoopInterface::tick怎么用?PHP LoopInterface::tick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在React\EventLoop\LoopInterface的用法示例。


在下文中一共展示了LoopInterface::tick方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: testFutureTickFiresBeforeIO

 public function testFutureTickFiresBeforeIO()
 {
     $stream = $this->createStream();
     $this->loop->addWriteStream($stream, function () {
         echo 'stream' . PHP_EOL;
     });
     $this->loop->futureTick(function () {
         echo 'future-tick' . PHP_EOL;
     });
     $this->expectOutputString('future-tick' . PHP_EOL . 'stream' . PHP_EOL);
     $this->loop->tick();
 }
开发者ID:smileytechguy,项目名称:nLine,代码行数:12,代码来源:AbstractLoopTest.php

示例3: wait

 /**
  * {@inheritdoc}
  */
 public function wait($unwrap = true)
 {
     if (null === $this->loop) {
         throw new \LogicException('You must set the loop before wait!');
     }
     while (HttpPromise::PENDING === $this->getState()) {
         $this->loop->tick();
     }
     if ($unwrap) {
         if (HttpPromise::REJECTED == $this->getState()) {
             throw $this->exception;
         }
         return $this->response;
     }
 }
开发者ID:php-http,项目名称:react-adapter,代码行数:18,代码来源:Promise.php

示例4: waitFor

 protected function waitFor(PromiseInterface $promise, LoopInterface $loop)
 {
     $resolved = null;
     $exception = null;
     $promise->then(function ($c) use(&$resolved) {
         $resolved = $c;
     }, function ($error) use(&$exception) {
         $exception = $error;
     });
     while ($resolved === null && $exception === null) {
         $loop->tick();
     }
     if ($exception !== null) {
         throw $exception;
     }
     return $resolved;
 }
开发者ID:clue,项目名称:bitbake-react,代码行数:17,代码来源:bootstrap.php

示例5: __invoke

 /**
  * @param array $requestArray
  * @return FutureArray
  */
 public function __invoke(array $requestArray)
 {
     $request = new Request($requestArray['http_method'], $requestArray['url'], $requestArray['headers'], $requestArray['body'], $requestArray['version']);
     $ready = false;
     $httpRequest = $this->requestFactory->create($request, $requestArray['client'], $this->httpClient, $this->loop);
     return new FutureArray($httpRequest->then(function (ResponseInterface $response) use(&$ready, $requestArray) {
         $ready = true;
         $responseArray = ['effective_url' => $requestArray['url'], 'body' => $response->getBody(), 'headers' => $response->getHeaders(), 'status' => $response->getStatusCode(), 'reason' => $response->getReasonPhrase(), 'version' => $response->getProtocolVersion()];
         return $responseArray;
     }, function ($error) use(&$ready) {
         $ready = true;
         return ['error' => $error];
     }), function () use(&$ready) {
         do {
             $this->loop->tick();
         } while (!$ready);
     });
 }
开发者ID:vucms,项目名称:ReactGuzzleRing,代码行数:22,代码来源:HttpClientAdapter.php

示例6: __invoke

 /**
  * @param RequestInterface $request
  * @param array $options
  * @return Promise
  */
 public function __invoke(RequestInterface $request, array $options)
 {
     $ready = false;
     $promise = new Promise(function () use(&$ready) {
         do {
             $this->loop->tick();
         } while (!$ready);
     });
     $this->requestFactory->create($request, $options, $this->httpClient, $this->loop)->then(function (ResponseInterface $response) use(&$ready, $promise) {
         $ready = true;
         $promise->resolve($response);
         $this->invokeQueue();
     }, function ($error) use(&$ready, $promise) {
         $ready = true;
         $promise->reject($error);
         $this->invokeQueue();
     });
     return $promise;
 }
开发者ID:wyrihaximus,项目名称:react-guzzle-psr7,代码行数:24,代码来源:HttpClientAdapter.php

示例7: tick

 /**
  * Perform a single iteration of the event loop.
  */
 public function tick()
 {
     $this->emit('tickStart');
     $this->loop->tick();
     $this->emit('tickDone');
 }
开发者ID:WyriHaximus,项目名称:reactphp-event-loop-inspector,代码行数:9,代码来源:LoopDecorator.php

示例8: tick

 /**
  * Execute a single event loop iteration
  */
 public function tick()
 {
     $this->reactor->tick();
 }
开发者ID:daverandom,项目名称:loopio,代码行数:7,代码来源:Loop.php

示例9: manyTicks

 private function manyTicks()
 {
     for ($i = 0; $i < 20; $i++) {
         $this->loop->tick();
     }
 }
开发者ID:pilat,项目名称:daemonizer,代码行数:6,代码来源:MasterControllerTest.php


注:本文中的React\EventLoop\LoopInterface::tick方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。