Queue

@return float|int
342754
public function checkQueue()
    {
        if ($this->delay == 0) {
            return 0;
        }
        $query = $this->pdo->prepare(<<<SQL
SELECT GREATEST(0, (delayUntil / 1000000) - UNIX_TIMESTAMP(CURTIME(6)))
FROM robotstxt__delay0
WHERE base = :base AND userAgent = :userAgent;
SQL
        );
        $query->bindValue('base', $this->base, \PDO::PARAM_STR);
        $query->bindValue('userAgent', $this->userAgent, \PDO::PARAM_STR);
        $query->execute();
        return $query->rowCount() > 0 ? floatval($query->fetch(\PDO::FETCH_COLUMN)) : 0;
    }
3468
public function dequeue () {
        if ($this->_c === 0)
            throw new Exception(\Yii::t ('yii' , 'The queue is empty.'));
        else {
            --$this->_c;
            return array_shift ($this->_d);
        }
    }
999750
public function push()
    {
        if (!is_callable(self::$howToUseQueue)) {
            throw new PhpSmsException('Expected define how to use the queue system by methods `queue`.');
        }
        try {
            $this->pushedToQueue = true;

            return call_user_func_array(self::$howToUseQueue, [$this, $this->all()]);
        } catch (\Exception $e) {
            $this->pushedToQueue = false;
            throw $e;
        }
    }
243827
public function ping()
    {
        Debug::Log(Debug::INFO, 'ping()');
        $this->simpleCommand(Message::PINGREQ);

        $this->ping_queue[] = time();

        return count($this->ping_queue);
    }
575994
def queue(self):
        """"""
        with self.connection_pool.acquire(block=True) as conn:
            return Q(
                self.routing_key,
                exchange=self.exchange,
                routing_key=self.routing_key
            )(conn)
755336
public function resolveQueues()
    {
        if (in_array('*', $this->queues)) {
            $queues = $this->redis->smembers(Queue::redisKey());
            is_array($queues) and sort($queues);
        } else {
            $queues = $this->queues;
        }

        if (!is_array($queues)) {
            $queues = array();
        }

        return $queues;
    }
578919
public function throughput()
    {
        return collect($this->measuredQueues())->reduce(function ($carry, $queue) {
            return $carry + $this->connection()->hget('queue:'.$queue, 'throughput');
        }, 0);
    }
347117
public function getMessageQueue()
	{
		// For empty queue, if messages exists in the session, enqueue them.
		if (!count($this->_messageQueue))
		{
			$session = JFactory::getSession();
			$sessionQueue = $session->get('application.queue');

			if (count($sessionQueue))
			{
				$this->_messageQueue = $sessionQueue;
				$session->set('application.queue', null);
			}
		}

		return $this->_messageQueue;
	}
284890
public function processQueue()
    {
        //Set items to 0
        $this->totalItems = 0;

        //Set bulk sync limit
        $this->bulkSyncLimit = 5;

        //Set priority
        $this->_setPriority();

        //Check previous import status
        $this->_checkImportStatus();

        //Bulk priority. Process group 1 first
        foreach ($this->bulkPriority as $bulk) {
            if ($this->totalItems < $bulk['limit']) {
                $collection = $this->_getQueue(
                    $bulk['type'],
                    $bulk['mode'],
                    $bulk['limit'] - $this->totalItems
                );
                if ($collection->getSize()) {
                    $this->totalItems += $collection->getSize();
                    $bulkModel = $this->objectManager->create($bulk['model']);
                    $bulkModel->sync($collection);
                }
            }
        }

        //reset total items to 0
        $this->totalItems = 0;

        //Single/Update priority.
        foreach ($this->singlePriority as $single) {
            if ($this->totalItems < $single['limit']) {
                $collection = $this->_getQueue(
                    $single['type'],
                    $single['mode'],
                    $single['limit'] - $this->totalItems
                );
                if ($collection->getSize()) {
                    $this->totalItems += $collection->getSize();
                    $singleModel = $this->objectManager->create(
                        $single['model']
                    );
                    $singleModel->sync($collection);
                }
            }
        }
    }
348439
protected function getQueue()
	{
		if (isset($this->meta)) return $this->meta;

		return $this->meta = $this->flyphp['queue']->getIron()->getQueue($this->argument('queue'));
	}
536281
public function tick()
    {
        $count = $this->queue->count();

        while ($count-- && $this->loop->isRunning())
        {
            $this->callback = $this->queue->dequeue();
            $callback = $this->callback; // without this proxy PHPStorm marks line as fatal error.
            $callback($this->loop);
        }
    }
1273423
public function getIterator()
    {
        $queue = new \SplPriorityQueue();

        $this->workers->rewind();
        while($this->workers->valid()) {

            $queue->insert(
                $this->workers->current(),
                $this->workers->getInfo()
            );

            $this->workers->next();
        }

        return $queue;
    }
585590
public function front() {
        if (null === $this->queue) return null;
        if ($this->tail > $this->head) return null;
        return $this->queue[$this->tail];
    }
301377
private function triggerQueueNow()
    {
        $url = UrlHelper::actionUrl('queue/run');

        if (\function_exists('curl_init')) {
            $ch = curl_init($url);

            $options = [
                CURLOPT_RETURNTRANSFER => true,
                CURLOPT_CONNECTTIMEOUT => false,
                CURLOPT_NOSIGNAL => true
            ];

            if (\defined('CURLOPT_TIMEOUT_MS')) {
                $options[CURLOPT_TIMEOUT_MS] = 500;
            } else {
                $options[CURLOPT_TIMEOUT] = 1;
            }

            curl_setopt_array($ch, $options);
            curl_exec($ch);
            curl_close($ch);
        }
    }
833005
protected function getQueue()
	{
		if (isset($this->meta)) return $this->meta;

		return $this->meta = $this->laravel['queue']->getIron()->getQueue($this->argument('queue'));
	}
45563
public function count($queueName = '')
    {
        if (isset($this->queues[$queueName])) {
            return count($this->queues[$queueName]);
        }
        return 0;
    }
662215
public function getMessagesCurrentCountOnQueue($queue)
    {
        try {
            return $this->queue->getQueue($queue)->size;
        } catch (\Http_Exception $ex) {
            \PHPUnit\Framework\Assert::fail("queue [$queue] not found");
        }
    }