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


PHP Queue::pop方法代码示例

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


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

示例1: pop

 /**
  * {@inheritdoc}
  */
 public function pop()
 {
     return $this->exceptional(function () {
         return $this->queue->pop();
     });
 }
开发者ID:rybakit,项目名称:phive-queue,代码行数:9,代码来源:ExceptionalQueue.php

示例2: start

 public function start()
 {
     if ($this->isActive || $this->isStopped) {
         return;
     }
     $this->isActive = true;
     $this->isStarted = true;
     $curlHandle = curl_multi_init();
     try {
         do {
             // send requests from queue to CURL
             if (count($this->activeRequests) < $this->connectionsLimit) {
                 for ($i = $this->connectionsLimit - count($this->activeRequests); $i > 0; $i--) {
                     $request = $this->queue->pop();
                     if ($request) {
                         $this->sendRequestToMultiCurl($curlHandle, $request);
                         $this->activeRequests[$request->getId()] = $request;
                     } else {
                         break;
                     }
                 }
             }
             while (CURLM_CALL_MULTI_PERFORM === curl_multi_exec($curlHandle, $activeThreads)) {
             }
             // check complete requests
             curl_multi_select($curlHandle, $this->requestingDelay);
             while ($completeCurlInfo = curl_multi_info_read($curlHandle)) {
                 $completeRequestId = Request::getRequestIdByCurlHandle($completeCurlInfo['handle']);
                 $completeRequest = $this->activeRequests[$completeRequestId];
                 unset($this->activeRequests[$completeRequestId]);
                 curl_multi_remove_handle($curlHandle, $completeRequest->getCurlHandle());
                 $completeRequest->handleCurlResult();
                 // check if response code is 301 or 302 and follow location
                 $ignoreNotification = false;
                 $completeRequestCode = $completeRequest->getCode();
                 if ($completeRequestCode == 301 || $completeRequestCode == 302) {
                     $completeRequestOptions = $completeRequest->getCurlOptions();
                     if (!empty($completeRequestOptions[CURLOPT_FOLLOWLOCATION])) {
                         $completeRequest->_permanentlyMoved = empty($completeRequest->_permanentlyMoved) ? 1 : $completeRequest->_permanentlyMoved + 1;
                         $responseHeaders = $completeRequest->getResponseHeaders(true);
                         if ($completeRequest->_permanentlyMoved < 5 && !empty($responseHeaders['Location'])) {
                             // figure out whether we're dealing with an absolute or relative redirect (thanks to kmontag https://github.com/kmontag for this bugfix)
                             $redirectedUrl = (parse_url($responseHeaders['Location'], PHP_URL_SCHEME) === null ? $completeRequest->getBaseUrl() : '') . $responseHeaders['Location'];
                             $completeRequest->setUrl($redirectedUrl);
                             $completeRequest->reInitCurlHandle();
                             $this->pushRequestToQueue($completeRequest);
                             $ignoreNotification = true;
                         }
                     }
                 }
                 if (!$ignoreNotification) {
                     $this->notifyRequestComplete($completeRequest);
                 }
             }
         } while (!$this->isStopped && ($this->activeRequests || $this->queue->count()));
     } catch (Exception $exception) {
     }
     $this->isActive = false;
     if ($curlHandle && is_resource($curlHandle)) {
         curl_multi_close($curlHandle);
     }
     if (!empty($exception)) {
         throw $exception;
     }
     /** @noinspection PhpUndefinedMethodInspection */
     $this->callbacks->onComplete($this);
 }
开发者ID:mostaphazeghaouigmail,项目名称:multirequest,代码行数:67,代码来源:Handler.php

示例3: pop

 /**
  * {@inheritdoc}
  */
 public function pop()
 {
     $item = $this->queue->pop();
     return unserialize(base64_decode($item));
 }
开发者ID:rybakit,项目名称:phive-queue,代码行数:8,代码来源:TypeSafeQueue.php

示例4: king

    {
        // 可优化: stack1的最后一个元素可直接出栈,这样少一次入栈出栈
        while (!$this->stack1->isEmpty()) {
            $this->stack2->push($this->stack1->pop());
        }
        return $this->stack2->pop();
    }
}
// 优化
// 入队时,先判断s1是否为空,如不为空,说明所有元素都在s1,此时将入队元素直接压入s1;如为空,要将s2的元素逐个“倒回”s1,再压入入队元素。
// 出队时,先判断s2是否为空,如不为空,直接弹出s2的顶元素并出队;如为空,将s1的元素逐个“倒入”s2,把最后一个元素弹出并出队
$que = new Queue();
$que->push('a');
$que->push('b');
$que->push('c');
$que->pop();
$que->pop();
$que->pop();
function king($n, $m)
{
    $monkey = range(1, $n);
    $i = 0;
    while (count($monkey) > 1) {
        $i += 1;
        $head = array_shift($monkey);
        if ($i % $m != 0) {
            array_push($monkey, $head);
        } else {
            echo $head, "\n";
        }
    }
开发者ID:ironxu,项目名称:aboutme,代码行数:31,代码来源:e.php

示例5: next

 public static function next($queueName)
 {
     $wrapCoroutine = Queue::pop($queueName);
     if ($wrapCoroutine) {
         self::wrap($wrapCoroutine);
     }
 }
开发者ID:jmuyuyang,项目名称:co-psf,代码行数:7,代码来源:Coroutine.php


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