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


PHP SplQueue::isEmpty方法代码示例

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


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

示例1: startPendingTasks

 /**
  * Starts pending tasks end move them from the pendingQueue to the runningQueue
  */
 private function startPendingTasks()
 {
     while (count($this->runningTasks) < $this->concurrencyLimit && !$this->pendingTasks->isEmpty()) {
         /** @var TaskInterface $task */
         $task = $this->pendingTasks->dequeue();
         $task->start()->progress(function (Event $notification) {
             $this->deferred->notify($notification);
         })->always(function () use($task) {
             $this->finishedTasks[] = $task;
             $this->deferred->notify(new TaskFinishedEvent($this, $task));
         });
         $this->deferred->notify(new TaskStartedEvent($this, $task));
         $this->runningTasks->enqueue($task);
     }
 }
开发者ID:jderusse,项目名称:async,代码行数:18,代码来源:MultiTasks.php

示例2: pop

 /**
  * @coroutine
  *
  * @return \Generator
  *
  * @resolve \Icicle\Postgres\Connection
  */
 private function pop() : \Generator
 {
     while (null !== $this->awaitable) {
         try {
             (yield $this->awaitable);
             // Prevent simultaneous connection creation.
         } catch (\Throwable $exception) {
             // Ignore failure or cancellation of other operations.
         }
     }
     if ($this->idle->isEmpty()) {
         try {
             if ($this->connections->count() >= $this->getMaxConnections()) {
                 // All possible connections busy, so wait until one becomes available.
                 $this->awaitable = new Delayed();
                 (yield $this->awaitable);
             } else {
                 // Max connection count has not been reached, so open another connection.
                 $this->awaitable = new Coroutine($this->createConnection());
                 $this->addConnection((yield $this->awaitable));
             }
         } finally {
             $this->awaitable = null;
         }
     }
     // Shift a connection off the idle queue.
     return $this->idle->shift();
 }
开发者ID:icicleio,项目名称:postgres,代码行数:35,代码来源:AbstractPool.php

示例3: close

 public function close()
 {
     if (!$this->promises->isEmpty()) {
         $this->promises->dequeue()->resolve();
     } else {
         $this->current--;
     }
 }
开发者ID:voidcontext,项目名称:filesystem,代码行数:8,代码来源:OpenFileLimiter.php

示例4: __invoke

 public function __invoke($id, $service)
 {
     if ($this->middlewares->isEmpty()) {
         return $service;
     }
     $method = $this->middlewares->dequeue();
     return call_user_func($method, $this->container, new Next($this->container, $this->middlewares), $id, $service);
 }
开发者ID:mrferos,项目名称:GenieDi,代码行数:8,代码来源:Next.php

示例5: uncork

 public function uncork()
 {
     if (!$this->corked) {
         return;
     }
     while (!$this->corked && !$this->writeBuffer->isEmpty()) {
         $this->doWrite(...$this->writeBuffer->dequeue());
     }
 }
开发者ID:joshdifabio,项目名称:object-stream,代码行数:9,代码来源:WritableObjectStreamTrait.php

示例6: tick

 private function tick()
 {
     while (!$this->tick->isEmpty() && !$this->main->isFinished()) {
         $task = $this->nextTask();
         $task->run();
         if ($task->isBlocked()) {
             $this->addFutureTask($task);
         }
     }
 }
开发者ID:crystalplanet,项目名称:redshift,代码行数:10,代码来源:EventLoop.php

示例7: getQuery

 /**
  * @inheritDoc
  */
 public function getQuery(Driver $driver, $link)
 {
     if (!$this->pool->contains($link)) {
         throw new \OutOfBoundsException(sprintf('Undefined %s in the pooling controller.', $driver->info($link)));
     }
     if (!$this->waiting->isEmpty()) {
         return $this->waiting->dequeue();
     }
     $this->idle->enqueue($link);
 }
开发者ID:repo2,项目名称:query-reactor,代码行数:13,代码来源:PoolingController.php

示例8: processQueue

 protected function processQueue()
 {
     $this->loop->addTimer($this->interval, function () {
         if ($this->callQueue->isEmpty()) {
             return;
         }
         $message = $this->callQueue->dequeue();
         $data = ['function' => $message->getFunction(), 'args' => $message->getArgs(), 'errorResultCode' => $message->getErrorResultCode()];
         $message->getDeferred()->resolve($data);
     });
 }
开发者ID:voidcontext,项目名称:filesystem,代码行数:11,代码来源:ThrottledQueuedInvoker.php

示例9: __invoke

 /**
  * @param Message $chapterCommand
  * @param mixed $data
  * @param ChapterLogger $chapterLogger
  */
 public function __invoke(Message $chapterCommand, $data, ChapterLogger $chapterLogger)
 {
     $done = $this->done;
     // No middleware remains; done
     if ($this->queue->isEmpty()) {
         return $done($chapterCommand, $data, $chapterLogger);
     }
     $stage = $this->queue->dequeue();
     $executeStage = $this->executeStage;
     return $executeStage($stage, $chapterCommand, $data, $chapterLogger, $this);
 }
开发者ID:proophsoftware,项目名称:done-process,代码行数:16,代码来源:Next.php

示例10: processQueue

 protected function processQueue()
 {
     $this->loop->futureTick(function () {
         if ($this->callQueue->isEmpty()) {
             return;
         }
         $this->runningOperations++;
         $message = $this->callQueue->dequeue();
         $data = ['function' => $message->getFunction(), 'args' => $message->getArgs(), 'errorResultCode' => $message->getErrorResultCode()];
         $message->getDeferred()->resolve($data);
     });
 }
开发者ID:voidcontext,项目名称:filesystem,代码行数:12,代码来源:PooledInvoker.php

示例11: run

 private function run()
 {
     /** @var HttpServer $server */
     $server = $this->container->get('http_server');
     // Run async dispatcher
     $server->getLoop()->addPeriodicTimer(Timer::MIN_INTERVAL, function (Timer $timer) {
         if ($this->queue->isEmpty()) {
             $timer->cancel();
             return;
         }
         $event = $this->queue->dequeue();
         $this->dispatch($event);
     });
 }
开发者ID:inisire,项目名称:framework,代码行数:14,代码来源:EventDispatcher.php

示例12: __invoke

 /**
  * @param Request $request
  * @param Response $response
  * @param callable[] ...$callables unshift callables (top priority)
  * @return Response
  */
 public function __invoke(Request $request, Response $response, ...$callables)
 {
     while ($callable = array_pop($callables)) {
         $this->queue->unshift($callable);
     }
     if ($this->queue->isEmpty()) {
         return $response;
     }
     $callable = $this->resolve($this->queue->dequeue());
     if (is_callable($callable)) {
         return call_user_func($callable, $request, $response, $this);
     } else {
         throw new \UnexpectedValueException();
     }
 }
开发者ID:assouan,项目名称:stretcher,代码行数:21,代码来源:Stretcher.php

示例13: endRead

 private function endRead()
 {
     $this->readEnded = true;
     if ($this->readBuffer->isEmpty()) {
         $this->ensureEndEmitted();
     }
 }
开发者ID:joshdifabio,项目名称:object-stream,代码行数:7,代码来源:ReadableObjectStreamTrait.php

示例14: processStateQueue

 /**
  * @param null $lastPublicationId
  */
 private function processStateQueue($lastPublicationId = null)
 {
     if ($lastPublicationId !== null) {
         // create an array of pub ids
         // if we can't find the lastPublicationId in the queue
         // then we are going to assume it was before our time
         $pubIds = [];
         /** @var EventMessage $msg */
         foreach ($this->pauseQueue as $msg) {
             $pubIds[] = $msg->getPublicationId();
         }
         if (!in_array($lastPublicationId, $pubIds)) {
             $lastPublicationId = null;
         }
     }
     while (!$this->pauseQueue->isEmpty()) {
         $msg = $this->pauseQueue->dequeue();
         if ($lastPublicationId === null) {
             $this->sendEventMessage($msg);
         }
         if ($lastPublicationId == $msg->getPublicationId()) {
             $lastPublicationId = null;
         }
     }
 }
开发者ID:voryx,项目名称:thruway,代码行数:28,代码来源:Subscription.php

示例15: render

 /**
  * Process the given queue of template files and
  * returns the generated output.
  *
  * @param string $file
  *
  * @return string
  * @throws RendererException
  */
 public function render(string $file) : string
 {
     if ($this->rendering) {
         throw new RendererException("Cannot call render() inside templates.");
     }
     $this->rendering = true;
     $this->queue->enqueue($file);
     $this->sections()->declare('content');
     ob_start();
     while (!$this->queue->isEmpty()) {
         $file = $this->engine->path($this->queue->dequeue());
         if (!file_exists($file)) {
             throw new \RuntimeException("Cannot find file: {$file}");
         }
         require $file;
         $this->sections()->populate('content', ob_get_contents(), 'replace');
         ob_clean();
         if ($this->extended) {
             $this->extended = false;
         }
     }
     ob_end_clean();
     $this->rendering = false;
     return $this->sections()->fetch('content');
 }
开发者ID:Trivivium,项目名称:Cascade,代码行数:34,代码来源:Renderer.php


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