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


PHP LoopInterface::stop方法代码示例

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


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

示例1: write

 /**
  * Listen for exit command and terminate
  * the event loop
  *
  * @param string $data
  * @return void
  */
 public function write($data)
 {
     if (trim($data) === self::EXIT_CMD) {
         $this->loop->stop();
         $this->close();
     }
 }
开发者ID:epfremmer,项目名称:PHP-Weekly-Issue25,代码行数:14,代码来源:QuitterStream.php

示例2: stop

 /**
  * Stops shell
  */
 public function stop()
 {
     if (!$this->running) {
         return;
     }
     $this->loop->stop();
     $this->running = false;
 }
开发者ID:fieg,项目名称:shell,代码行数:11,代码来源:Shell.php

示例3: stop

 /**
  * {@inheritdoc}
  */
 public function stop()
 {
     if (null !== $this->loop) {
         $this->loop->stop();
         $this->httpServer->removeAllListeners();
         $this->httpServer = null;
         $this->socketServer->shutdown();
         $this->socketServer = null;
         $this->loop = null;
     }
 }
开发者ID:syrma-php,项目名称:web-container,代码行数:14,代码来源:ReactServer.php

示例4: fanout

 /**
  * Create a queue with fanout exchange.
  *
  * @param string $exchange
  * @param string $queue
  *
  * @return PromiseInterface
  */
 public function fanout($exchange, $queue)
 {
     if (!isset($this->queues[$queue])) {
         $this->queues[$queue] = $this->connect()->then(function (Channel $channel) use($exchange, $queue) {
             return \React\Promise\all([$channel, $channel->queueDeclare($queue), $channel->exchangeDeclare($exchange, 'fanout'), $channel->queueBind($queue, $exchange)]);
         }, function (Exception $exception) {
             $this->loop->stop();
             throw new AsyncMessagingException(sprintf('Could not create channel and exchange: %s on line %s in file %s', $exception->getMessage(), $exception->getLine(), $exception->getFile()), 0, $exception);
         });
     }
     return $this->queues[$queue];
 }
开发者ID:simgroep,项目名称:event-sourcing,代码行数:20,代码来源:ChannelFactory.php

示例5: terminate

 public function terminate()
 {
     $this->loop->stop();
     $this->daemon->terminate();
     // @codeCoverageIgnoreStart
     if (!defined('PHPUNIT_TEST')) {
         define('PHPUNIT_TEST', false);
     }
     // @codeCoverageIgnoreEnd
     if (!PHPUNIT_TEST) {
         die;
     }
 }
开发者ID:pilat,项目名称:daemonizer,代码行数:13,代码来源:ChildController.php

示例6: consumeMessage

 /**
  * @param callable $callback
  *
  * @return void
  */
 protected function consumeMessage(callable $callback)
 {
     $this->channelFactory->fanout($this->exchange, $this->channel)->then(function ($r) use($callback) {
         /** @var Channel $channel */
         $channel = $r[0];
         return $channel->consume(function (Message $message) use($callback) {
             $data = json_decode($message->content, true);
             $callback($this->serializer->deserialize(null, $data));
         }, $this->channel, '', false, true);
     }, function (Exception $exception) {
         $this->loop->stop();
         throw new AsyncMessagingException(sprintf('Could not consume message: %s on line %s in file %s', $exception->getMessage(), $exception->getLine(), $exception->getFile()), 0, $exception);
     });
 }
开发者ID:simgroep,项目名称:event-sourcing,代码行数:19,代码来源:AbstractFanoutConsumer.php

示例7: stop

 public function stop()
 {
     $this->peersInbound->close();
     $this->peersOutbound->close();
     $this->loop->stop();
     $this->db->stop();
 }
开发者ID:sbwdlihao,项目名称:node-php,代码行数:7,代码来源:BitcoinNode.php

示例8: sendTasks

 /**
  * Action time for master! Send tasks `to-do` for workers and go to sleep.
  * Also decide when to stop server/loop.
  */
 public function sendTasks()
 {
     if (!$this->wait) {
         if (count($this->tasks) > 0) {
             // Get task name to do.
             $task = current($this->tasks);
             $taskName = $task->getName();
             array_shift($this->tasks);
             $this->informer->startTask($taskName);
             if ($task->isOnce()) {
                 $task->run(new Context(null, null, $this->input, $this->output));
                 $this->informer->endTask();
             } else {
                 $this->tasksToDo = [];
                 foreach ($this->servers as $serverName => $server) {
                     if ($task->runOnServer($serverName)) {
                         $env = isset($this->environments[$serverName]) ? $this->environments[$serverName] : ($this->environments[$serverName] = new Environment());
                         if (count($task->getOnlyForStage()) > 0 && (!$env->has('stages') || !$task->runForStages($env->get('stages')))) {
                             continue;
                         }
                         $this->informer->onServer($serverName);
                         $this->tasksToDo[$serverName] = $taskName;
                     }
                 }
                 // Inform all workers what tasks they need to do.
                 $taskToDoStorage = new ArrayStorage();
                 $taskToDoStorage->push($this->tasksToDo);
                 $this->pure->setStorage('tasks_to_do', $taskToDoStorage);
                 $this->wait = true;
             }
         } else {
             $this->loop->stop();
         }
     }
 }
开发者ID:irfan,项目名称:deployer,代码行数:39,代码来源:ParallelExecutor.php

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

示例10: sendTasks

 /**
  * Action time for master! Send tasks `to-do` for workers and go to sleep.
  * Also decide when to stop server/loop.
  */
 public function sendTasks()
 {
     if (!$this->wait) {
         if (count($this->tasks) > 0) {
             // Get task name to do.
             $task = current($this->tasks);
             $taskName = $task->getName();
             array_shift($this->tasks);
             $this->informer->startTask($taskName);
             if ($task->isOnce()) {
                 $task->run(new Context($this->localhost, $this->localEnv, $this->input, $this->output));
                 $this->informer->endTask();
             } else {
                 $this->tasksToDo = [];
                 foreach ($this->servers as $serverName => $server) {
                     if ($task->isOnServer($serverName)) {
                         if (!isset($this->environments[$serverName])) {
                             $this->environments[$serverName] = new Environment();
                         }
                         // Start task on $serverName.
                         $this->tasksToDo[$serverName] = $taskName;
                     }
                 }
                 // Inform all workers what tasks they need to do.
                 $taskToDoStorage = new ArrayStorage();
                 $taskToDoStorage->push($this->tasksToDo);
                 $this->pure->setStorage('tasks_to_do', $taskToDoStorage);
                 $this->wait = true;
             }
         } else {
             $this->loop->stop();
         }
     }
 }
开发者ID:elfet,项目名称:deployer,代码行数:38,代码来源:ParallelExecutor.php

示例11: stop

 /**
  * Disconnect and stop the event loop
  */
 public function stop()
 {
     $this->wsClient->close();
     $this->ariClient->onClose(function () {
         $this->eventLoop->stop();
     });
 }
开发者ID:wormling,项目名称:phparia,代码行数:10,代码来源:Phparia.php

示例12: consume

 public function consume($topic, $channel, $payload)
 {
     if (!count($this->messages)) {
         return;
     }
     try {
         if (!$this->exception) {
             $this->checkMessage($topic, $channel, $payload);
         }
     } catch (\PHPUnit_Framework_AssertionFailedError $e) {
         $this->exception = $e;
     }
     if (count($this->messages) == 0) {
         $this->loop->stop();
     }
 }
开发者ID:smilesrg,项目名称:NsqBundle,代码行数:16,代码来源:TopicTest.php

示例13: publishMessage

 /**
  * @param QueueMessage $message
  *
  * @return void
  */
 protected function publishMessage(QueueMessage $message)
 {
     $this->channelFactory->fanout($this->exchange, $this->channel)->then(function ($r) use($message) {
         /** @var Channel $channel */
         $channel = $r[0];
         return \React\Promise\all([$channel->publish(json_encode($this->serializer->serialize($message)), [], $this->exchange)]);
     }, function (Exception $exception) {
         $this->loop->stop();
         throw new AsyncMessagingException(sprintf('Could not publish message: %s on line %s in file %s', $exception->getMessage(), $exception->getLine(), $exception->getFile()), 0, $exception);
     })->then(function () {
         $this->loop->stop();
     }, function (Exception $exception) {
         $this->loop->stop();
         var_dump(sprintf('Could not publish message: %s on line %s in file %s', $exception->getMessage(), $exception->getLine(), $exception->getFile()));
     });
     $this->loop->run();
 }
开发者ID:simgroep,项目名称:event-sourcing,代码行数:22,代码来源:AbstractFanoutPublisher.php

示例14: stop

 /**
  * Calls {@link eventLoop}'s stop() method.
  */
 public function stop()
 {
     if ($this->stopTimer) {
         $this->stopTimer->cancel();
         $this->stopTimer = null;
     }
     $this->eventLoop->stop();
 }
开发者ID:Andrewsville,项目名称:bunny,代码行数:11,代码来源:Client.php

示例15: checkSigterm

 /**
  * Checks if the SIGTERM is presente in the server.
  */
 protected function checkSigterm()
 {
     if ($this->sigterm) {
         $this->loop->stop();
         $this->socket->shutdown();
         $this->output->writeln('The Foreman Processor has been stopped.');
     }
 }
开发者ID:naroga,项目名称:foreman,代码行数:11,代码来源:Processor.php


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