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