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


PHP Queue::count方法代码示例

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


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

示例1: 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

示例2: count

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

示例3: count

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


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