當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。