Retrieve the next job from the queue.

@param  string $queue
@return array
199422
protected function retrieveNextJob($queue)
    {
        if (! is_null($this->blockFor)) {
            return $this->blockingPop($queue);
        }

        return $this->getConnection()->eval(
            LuaScripts::pop(), 2, $queue, $queue.':reserved',
            $this->availableAt($this->retryAfter)
        );
    }
1162738
public function pop($queue = null)
    {
        $queue = $this->getQueue($queue);

        $job = $this->pheanstalk->watchOnly($queue)->reserve(0);

        if ($job instanceof Pheanstalk_Job) {
            return new BeanstalkdJob($this->container, $this->pheanstalk, $job, $queue);
        }
    }
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);
    }
1281417
protected function getNextAvailableJob($queue)
    {
        $expiration = Carbon::now()->subSeconds($this->retryAfter)->getTimestamp();
        $sql = 'SELECT * FROM ' . $this->table . ' WHERE queue =\'' . $this->getQueue($queue) . '\' 
                AND (
                        (reserved_at is NULL AND available_at <=' . $this->currentTime() . ')
                        OR 
                        (reserved_at <= ' . $expiration . ')
                    ) 
                order by id asc limit 1 ';

        $job = $this->database->createCommand($sql)->queryOne();

        return $job ? new DatabaseJobRecord((object)$job) : null;
    }
332939
public function peekQueue($queueName, $index = 0, $limit = 20)
    {
        if ($messages = $this->ironmq->peekMessages($queueName, $limit)) {
            return $this->pluck($messages, 'body');
        }

        return [];
    }
106342
public function peek(int $limit = 1): array
    {
        if ($limit !== 1) {
            throw new JobQueueException('The beanstalkd Jobqueue implementation currently only supports to peek one job at a time', 1352717703);
        }
        try {
            $pheanstalkJob = $this->client->peekReady($this->name);
        } catch (ServerException $exception) {
            return [];
        }
        if ($pheanstalkJob === null || $pheanstalkJob === false) {
            return [];
        }

        return [new Message((string)$pheanstalkJob->getId(), json_decode($pheanstalkJob->getData(), true))];
    }
1329496
public function get(string $queue = 'default', $isAck = true, $timeout = null)
    {
        yield $this->beanstalkTask->watch($queue);
        $job = yield $this->beanstalkTask->reserve($timeout);
        if ($job && $isAck) {
            yield $this->beanstalkTask->delete($job);
        }

        return $job;
    }
210534
public function getQueueSettings(string $queueName): array
    {
        if (isset($this->queueSettingsRuntimeCache[$queueName])) {
            return $this->queueSettingsRuntimeCache[$queueName];
        }
        if (!isset($this->settings['queues'][$queueName])) {
            throw new JobQueueException(sprintf('Queue "%s" is not configured', $queueName), 1334054137);
        }
        $queueSettings = $this->settings['queues'][$queueName];
        if (isset($queueSettings['preset'])) {
            $presetName = $queueSettings['preset'];
            if (!isset($this->settings['presets'][$presetName])) {
                throw new JobQueueException(sprintf('Preset "%s", referred to in settings for queue "%s" is not configured', $presetName, $queueName), 1466677893);
            }
            $queueSettings = Arrays::arrayMergeRecursiveOverrule($this->settings['presets'][$presetName], $queueSettings);
        }
        $this->queueSettingsRuntimeCache[$queueName] = $queueSettings;
        return $this->queueSettingsRuntimeCache[$queueName];
    }
891875
function Next($rs)
	{
		$this->RequireConnection();
		
		$this->handler->Log(DBH_LOG_DEBUG, "Fetching next result as array");
		return $this->adapter->Fetch($rs);

	}
21779
public function pop($queue = null)
	{
		$queue = $this->getQueue($queue);

		$this->database->beginTransaction();

		if ($job = $this->getNextAvailableJob($queue)) {
			$job = $this->markJobAsReserved($job);

			$this->database->commit();

			return new DatabaseJob(
				$this->container, $this, $job, $queue
			);
		}

		$this->database->commit();
	}
615041
public function getQueues(array $queueAlias): array
    {
        $queues = [];
        foreach ($queueAlias as $alias) {
            $queues[] = $this->getQueue($alias);
        }

        return $queues;
    }
398250
public static function pop($queue)
    {
        $item = self::redis()->lpop('queue:' . $queue);
        if (!$item) {
            return;
        }

        return json_decode($item, true);
    }
279150
private function runQueue($queue, $worker)
    {
        $result['count'] = 0;
        $result['total'] = $queue->numberOfItems();
        while ($item = $queue->claimItem()) {
            try {
                $worker->processItem($item->data);
                $queue->deleteItem($item);
                $result['count']++;
            } catch (SuspendQueueException $e) {
                $queue->releaseItem($item);
                $result['error'] = $e;
            }
        }

        return $result;
    }
443578
public function pop($queue = null)
	{
		$queue = $this->getQueue($queue);

		if ( ! is_null($this->expire))
		{
			$this->releaseJobsThatHaveBeenReservedTooLong($queue);
		}

		if ($job = $this->getNextAvailableJob($queue))
		{
			$this->markJobAsReserved($job->id);

			$this->database->commit();

			return new DatabaseJob(
				$this->container, $this, $job, $queue
			);
		}

		$this->database->commit();
	}
961641
protected function getNextAvailableJob($queue)
	{
		$this->database->beginTransaction();

		$job = $this->database->table($this->table)
					->lockForUpdate()
					->where('queue', $this->getQueue($queue))
					->where('reserved', 0)
					->where('available_at', '<=', $this->getTime())
					->orderBy('id', 'asc')
					->first();

		return $job ? (object) $job : null;
	}
1352382
public function dequeue()
    {
        $queues = $this->registry->all();

        if (null !== $this->prefix) {
            $wildcardQueue = $this;
            $queues = array_filter(
                $queues,
                function (QueueInterface $queue) use ($wildcardQueue) {
                    return (0 === strpos($queue->getName(), $wildcardQueue->getPrefix()));
                }
            );
        }

        ksort($queues);

        foreach ($queues as $queue) {
            if (null !== $job = $queue->dequeue()) {
                return $job;
            }
        }

        return null;
    }
1087455
protected function get($queueName)
    {
        if (isset($this->caches[$queueName])) {
            return $this->caches[$queueName];
        }

        return $this->caches[$queueName] = new \SplQueue();
    }