本文整理汇总了PHP中SplQueue::dequeue方法的典型用法代码示例。如果您正苦于以下问题:PHP SplQueue::dequeue方法的具体用法?PHP SplQueue::dequeue怎么用?PHP SplQueue::dequeue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SplQueue
的用法示例。
在下文中一共展示了SplQueue::dequeue方法的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);
}
}
示例2: getLoggedEvent
/**
* @return LogEvent
*/
public function getLoggedEvent() : LogEvent
{
if (!$this->hasLoggedEvents()) {
throw new \LogicException('No more events logged!');
}
return $this->logs->dequeue();
}
示例3: onExit
public function onExit($status)
{
if ($this->pendingRequests->count() > 0) {
$nextExpectedTest = $this->pendingRequests->dequeue();
$this->distributor->testCompleted($this, TestResult::errorFromRequest($nextExpectedTest, "Worker{$this->id} died\n{$this->testErr}"));
}
}
示例4: pop
/** @return Error|null */
public static function pop()
{
if (!self::$errors) {
return null;
}
return self::$errors->count() > 0 ? self::$errors->dequeue() : null;
}
示例5: deliver
/**
* Deliver notifications via given instance of Notifier
* @param Notifier $notifier
*/
public function deliver(Notifier $notifier)
{
foreach ($this->queue as $notification) {
$notifier->notify($notification);
$this->queue->dequeue();
}
}
示例6: __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);
}
示例7: close
public function close()
{
if (!$this->promises->isEmpty()) {
$this->promises->dequeue()->resolve();
} else {
$this->current--;
}
}
示例8: uncork
public function uncork()
{
if (!$this->corked) {
return;
}
while (!$this->corked && !$this->writeBuffer->isEmpty()) {
$this->doWrite(...$this->writeBuffer->dequeue());
}
}
示例9: 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);
}
示例10: processQueue
protected function processQueue()
{
$this->loop->futureTick(function () {
if ($this->callQueue->isEmpty()) {
return;
}
$message = $this->callQueue->dequeue();
$data = ['function' => $message->getFunction(), 'args' => $message->getArgs(), 'errorResultCode' => $message->getErrorResultCode()];
$message->getDeferred()->resolve($data);
});
}
示例11: releaseConnection
/**
* Once a connection has finished being used...
* @param Connection $connection
*/
public function releaseConnection(Connection $connection)
{
// If we have any promises waiting for the connection, pass it along.
if ($this->waiting->count() > 0) {
$cb = $this->waiting->dequeue();
$cb($connection);
return;
}
// Otherwise, move it to the idle queue.
$this->available->enqueue($connection);
}
示例12: __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);
}
示例13: 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);
});
}
示例14: __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();
}
}
示例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');
}