Get the next available job for the queue.

@param  string|null  $queue
@return \StdClass|null
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;
	}
468401
function getQueue($token)
	{
		$a = func_get_args();
		Debugger::log(__CLASS__ . ": " . __METHOD__ . "; args: " . print_r($a, true));

		$q = new Queue();
		$q->setQueueID($token);
		$q->setQueuesModel($this);
		return $q;
	}
81558
public static function get( $slug ) {
		return isset( self::$queues[ $slug ] ) ? self::$queues[ $slug ] : null;
	}
735082
public function fetchFirstObj(string $class = null)
    {
        if (!$this->wasExecuted()) {
            $this->exec();
        }

        $data = $this->fetchFirst();

        if ($data === null) {
            return null;
        }

        if ($class == null) {
            $obj = new \stdClass();

            foreach ($data as $field => $value) {
                $obj->$field = $value;
            }

            return $obj;
        } else {
            return new $class($data);
        }
    }
124539
public function later($delay, Queue $queue)
    {
        $connection = property_exists($this, 'connection') ? $this->connection : null;

        $queueName = property_exists($this, 'queue') ? $this->queue : null;

        return $queue->connection($connection)->laterOn(
            $queueName ?: null, $delay, new SendQueuedMailable($this)
        );
    }
138099
public function pop($queue = null)
    {
        $queue = $this->getQueue($queue);

        return $this->database->transaction(function () use ($queue)
        {
            if (! is_null($job = $this->getNextAvailableJob($queue))) {
                $this->markJobAsReserved($job->id, $job->attempts);

                return new DatabaseJob(
                    $this->container, $this, $job, $queue
                );
            }
        });
    }
247631
private function getConfigurationByQueue($queue)
    {
        if($this->reset($queue)) {
            return null;
        }

        if ($this->hasRunningJobInQueue($queue)) {
            return null;
        }

        return $this->configurationManager->findNextByQueue($queue);
    }
759178
public function getFailedJobs($queue)
    {
        try {
            $list = collect(app('queue.failer')->all())->where('queue', $queue->tube)
                                                       ->where('connection', $queue->connection);

            $list->map(function ($job) {
                $job = $this->mapJob($job);
            });

            return $list;
        } catch (Exception $e) {
            $this->eye->logger()->error('Unable to get Queue Failed Jobs', $e, $queue->id);
        }

        return collect([]);
    }
234603
public function getMessagesCurrentCountOnQueue($queue)
    {
        try {
            return $this->queue->statsTube($queue)['current-jobs-ready'];
        } catch (ConnectionException $e) {
            \PHPUnit\Framework\Assert::fail("queue [$queue] not found");
        }
    }
565877
public function push($job, array $data = null, $queue = null)
    {
        if (false !== ($delay = \Resque::getConfig('default.jobs.delay', false))) {
            return $this->later($delay, $job, $data, $queue);
        }

        return Job::create($this->getQueue($queue), $job, $data);
    }
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;
    }
451761
public function pop($queue = null)
    {
        if (static::supportDelayed()) {
            $this->requeueDelayedItems();
        }

        $queue = $queue ?: $this->queue;

        $job = Resque::pop($queue);

        if (!$job) {
            return null;
        }

        $message = new QueueMessage();

        $attempts = $job['attempts'];
        $attempts++;

        $message->setId($job['id']);
        $message->setBody($job);
        $message->setRawBody(json_encode($job));
        $message->setQueueName($queue ?: $this->queue);
        $message->setAttempts($attempts);
        $message->set('attempts', $attempts);

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

		$job = $this->iron->getMessage($queue);

		// If we were able to pop a message off of the queue, we will need to decrypt
		// the message body, as all Iron.io messages are encrypted, since the push
		// queues will be a security hazard to unsuspecting developers using it.
		if ( ! is_null($job))
		{
			$job->body = $this->crypt->decrypt($job->body);

			return new IronJob($this->container, $this, $job);
		}
	}
662215
public function getMessagesCurrentCountOnQueue($queue)
    {
        try {
            return $this->queue->getQueue($queue)->size;
        } catch (\Http_Exception $ex) {
            \PHPUnit\Framework\Assert::fail("queue [$queue] not found");
        }
    }
882960
function getNextJob(){
  let job = null;

  while(!job && queue.size() > 0){
    let id = queue.pop().id;
    job = map[id];
  }

  return (!!job)?job:null;
}
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;
    }
726116
public function pop($queue = null)
    {
        $original = $queue ?: $this->default;

        $queue = $this->getQueue($queue);

        if (!is_null($this->expire)) {
            $this->migrateAllExpiredJobs($queue);
        }
        $job = $this->getConnection()->lPop($queue);

        if ($job) {
            $this->getConnection()->zAdd($queue . ':reserved', $this->getTime() + $this->expire, $job);

            return new PHPRedisJob($this->container, $this, $job, $original);
        }
    }