Get the queue that has the longest runtime.

@return int
175087
public function queueWithMaximumRuntime()
    {
        return collect($this->measuredQueues())->sortBy(function ($queue) {
            if ($snapshots = $this->connection()->zrange('snapshot:queue:'.$queue, -1, 1)) {
                return json_decode($snapshots[0])->runtime;
            }
        })->last();
    }
179361
protected function getQueueSortingCallback()
    {
        // [$resourceId => $parentId]
        $parentMap = $this->registry->getParentMap();

        // [$resourceId => $priority]
        $priorityMap = $this->registry->getEventPriorityMap();

        /**
         * Returns whether or not $a is a child of $b.
         *
         * @param string $a
         * @param string $b
         *
         * @return bool
         *
         * @todo Move in resource registry
         */
        $isChildOf = function($a, $b) use ($parentMap) {
            while (isset($parentMap[$a])) {
                $parentId = $parentMap[$a];
                if ($parentId === $b) {
                    return true;
                }
                $a = $parentId;
            }
            return false;
        };

        return function ($a, $b) use ($isChildOf, $priorityMap) {
            $aId = $this->getEventPrefix($a);
            $bId = $this->getEventPrefix($b);

            // By prefix (resource id) priority
            $aPriority = isset($priorityMap[$aId]) ? $priorityMap[$aId] : 0;
            $bPriority = isset($priorityMap[$bId]) ? $priorityMap[$bId] : 0;

            if ($aPriority > $bPriority) {
                return -1;
            } elseif ($bPriority > $aPriority) {
                return 1;
            }

            // By resource hierarchy (children first)
            if ($isChildOf($aId, $bId)) {
                // B is a parent of A
                return -1;
            } elseif ($isChildOf($bId, $aId)) {
                // A is a parent of B
                return 1;
            }

            // By suffix priority
            $aPriority = $this->getEventPriority($a);
            $bPriority = $this->getEventPriority($b);

            if ($aPriority > $bPriority) {
                return -1;
            } elseif ($bPriority > $aPriority) {
                return 1;
            }

            return 0;
        };
    }
164814
protected function getMax()
	{
		if ( ! $this->locked) {
			//\Log::info('Should lock before changes');
		}

		$dql = "SELECT MAX(e.right) FROM {$this->className} e";
		$dql .= $this->getAdditionalCondition('WHERE');
		$query = $this->entityManager
				->createQuery($dql);
		$max = (int) $query->getSingleScalarResult();

		// Maybe array helper stores even bigger value.
		// In reality it won't happen because items are flushed on DQL run.
		$maxArrayHelper = $this->arrayHelper->getCurrentMax();
		$max = max($max, $maxArrayHelper);

		return $max;
	}
485682
public function get() {
        $num_conns = count($this->queue);
        if ($num_conns < $this->pool_size) {
            try {
                $this->make_conn();
            } catch (NoServerAvailable $e) {
                if ($num_conns == 0)
                    throw $e;
            }
        }
        return array_shift($this->queue);
    }
171901
public function getNextRunDate()
    {
        if ($this->nextRunDate === null) {
            $nextRun = $this->cronExpression->getNextRunDate();
            $this->nextRunDate = $nextRun->getTimestamp();
        }

        return $this->nextRunDate;
    }
1118682
public function getRuntimePath()
    {
        if ($this->_runtimePath === null) {
            $this->_runtimePath = $this->getAlias('@runtime');
        }

        return $this->_runtimePath;
    }
574791
public static int getQueueSize() {
        if (instance != null && instance.executor != null) {
            return instance.executor.getQueue().size();
        } else {
            return 0;
        }
    }
1326216
public function get_current_run() {
        global $CFG;

        // Get number of parallel runs if not passed.
        if (empty($this->currentrun) && ($this->currentrun !== false) && !empty($CFG->behatrunprocess)) {
            $this->currentrun = $CFG->behatrunprocess;
        }

        return $this->currentrun;
    }
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;
    }
1024619
public function get_maximum_tries() {
        $max = 1;
        foreach ($this->get_response_class_ids() as $responseclassid) {
            $max = max($max, $this->get_response_class($responseclassid)->get_maximum_tries());
        }
        return $max;
    }
35897
public function countMessagesInQueues(): int
    {
        return array_sum(array_map(function ($queueName) {
            return $this->queue($queueName)->declareQueue();
        }, $this->getQueueNames()));
    }
11231
public function getCurrentMessageCount()
    {
        // Save the current queue flags and setup the queue in passive mode
        $flags = $this->queue->getFlags();
        $this->queue->setFlags($flags | AMQP_PASSIVE);

        // Declare the queue again as passive to get the count of messages
        $messagesCount = $this->queue->declareQueue();

        // Restore the queue flags
        $this->queue->setFlags($flags);

        return $messagesCount;
    }
1014473
private function getWaitInterval()
    {
        if ($this->queuer instanceof QueueInterface) {
            $waitTime = $this->iterationsWithOutTask * self::WAIT_INTERVAL;

            return min($waitTime, self::MAX_SLEEPING_TIME_FOR_DEDICATED_QUEUE);
        } else if ($this->queuer instanceof QueueDispatcherInterface) {
            return (int) $this->queuer->getWaitTime();
        } else {
            return self::WAIT_INTERVAL;
        }
    }
101227
public function getQueues()
    {
        // Format the output to suit
        $queues = [];
        foreach ($this->queue->getQueues() as $queue) {
            $queues[] = $queue->name;
        }
        return $queues;
    }
659452
public function getLastPage()
    {
        return (int) \max(self::MIN_PAGE, \ceil($this->getTotal() / $this->getLimit()));
    }
549680
public function getCurrentMax()
	{
		$max = 0;
		/* @var $node Node\NodeInterface */
		foreach ($this->array as $node) {
			$max = max($max, $node->getRightValue());
		}
		return $max;
	}
147634
protected function getQueue()
        {
            if (null === $this->queue) {
                $this->queue = new $this->queueClass();

                if (!$this->queue instanceof SplPriorityQueue) {
                    throw new Exception(sprintf(
                        'Queue expects an internal queue of type SplPriorityQueue; received "%s"',
                        get_class($this->queue)
                    ));
                }
            }

            return $this->queue;
        }