Obtain a job from the pipeline for the given Employee.
@return \Emphloyer\Job|null
19852
public function getWork(Employee $employee)
    {
        $job = $this->pipeline->dequeue($employee->getOptions());

        if (is_null($job)) {
            usleep(10000);
        }

        return $job;
    }
107306
public function getNextJob(): ?Job
    {
        if ($this->hasAtJobsToProcess() && $this->hasCronJobsToProcess()) {
            return $this->findNextJob();
        }

        if ($this->hasAtJobsToProcess()) {
            return $this->getNextAtJob();
        }

        return $this->getNextCronJob();
    }
462287
public function job()
    {
        $job = $this->resqueInstance->redis->get(self::WORKER_NAME . ':' . $this);
        if (!$job) {
            return [];
        } else {
            return json_decode($job, true);
        }
    }
1318021
public function getJob()
    {
        $this->resolveChildren();

        $job = new Job($this->getJobConfig());

        foreach ($this->children as $child) {
            $job->add($child->getJob());
        }

        return $job;
    }
1098613
private function getNextCronJob(): ?Job
    {
        $cron_id = $this->getNextCronId();

        if (is_null($cron_id)) {
            return null;
        }

        $key = sprintf('%s:%s', self::CRON_QUEUE_NAME, $cron_id);

        $data = json_decode($this->client->get($key), true);

        $this->updateCron($cron_id, $data['cron']);

        $job = $data['job'];

        return new Job($job['class'], $job['queue'], $job['args']);
    }
578353
protected function findNextJob(): ?Job
    {
        $next_at_timestamp = $this->getNextAtTimestamp();
        $cron_id = $this->getNextCronId();

        if (is_null($cron_id)) {
            return $this->getNextAtJob();
        }

        $next_cron_timestamp = $this->getCronTimestamp($cron_id);

        if ($next_at_timestamp <= $next_cron_timestamp) {
            return $this->getNextAtJob();
        }

        return $this->getNextCronJob();
    }
201769
public function enqueue()
    {
        $this->out('<info>' . __d('cake_resque', 'Adding a job to worker') . '</info>');
        if (count($this->args) !== 3) {
            $this->err('<error>' . __d('cake_resque', 'Wrong number of arguments') . '</error>');
            $this->out(__d('cake_resque', 'Usage : enqueue <queue> <jobclass> <comma-separated-args>'), 2);

            return false;
        }

        $result = CakeResque::enqueue($this->args[0], $this->args[1], explode(',', $this->args[2]));

        $this->out('<success>' . __d('cake_resque', 'Succesfully enqueued Job #{0}', $result) . '</success>');

        $this->out('');
    }
416702
public function getNextJob()
    {
        $jobInfo = $this->broker->get();

        if (!class_exists($jobInfo['class'])) {
            $this->logger->error("Class {$jobInfo['class']} for scheduled job not found");
            return false;
        }

        $job = unserialize($jobInfo['object']);

        if (is_object($job) && is_a($job, '\ajumamoro\Job')) {
            $job->setId($jobInfo['id']);
            return $job;
        } else {
            $this->logger->error("Scheduled job is not of type \\ajumamoro\\Job");
            return false;
        }
    }
1136962
protected function retrieveNextJob($queue, $block = true)
    {
        $nextJob = $this->getConnection()->eval(
            LuaScripts::pop(), 3, $queue, $queue.':reserved', $queue.':notify',
            $this->availableAt($this->retryAfter)
        );

        if (empty($nextJob)) {
            return [null, null];
        }

        [$job, $reserved] = $nextJob;

        if (! $job && ! is_null($this->blockFor) && $block &&
            $this->getConnection()->blpop([$queue.':notify'], $this->blockFor)) {
            return $this->retrieveNextJob($queue, false);
        }

        return [$job, $reserved];
    }
300140
public function job()
	{
		$job = Resque::redis()->get('worker:' . $this);
		if(!$job) {
			return array();
		}
		else {
			return json_decode($job, true);
		}
	}
805576
public function getWorker()
    {
        if ($this->_worker===null) {
            $config = Config::getInstance();
            $this->setupWorker($config);
        }

        return $this->_worker;
    }
337553
public function getNewJob() {
        # we can grab a locked job if we own the lock
        $rs = $this->runQuery("
            SELECT id
            FROM   " . self::$jobsTable . "
            WHERE  queue = ?
            AND    (run_at IS NULL OR NOW() >= run_at)
            AND    (locked_at IS NULL OR locked_by = ?)
            AND    failed_at IS NULL
            AND    attempts < ?
            ORDER BY created_at DESC
            LIMIT  10
        ", array($this->queue, $this->name, $this->max_attempts));

        // randomly order the 10 to prevent lock contention among workers
        shuffle($rs);

        foreach ($rs as $r) {
            $job = new DJJob($this->name, $r["id"], array(
                "max_attempts" => $this->max_attempts,
                "fail_on_output" => $this->fail_on_output
            ));
            if ($job->acquireLock()) return $job;
        }

        return false;
    }
613219
public function setJob($job_model)
    {
        if ($this->isCanceledJob($job_model)) {
            return null;
        }

        $job_id = $this->getQuery('job_id');

        if (empty($job_id)) {
            return null;
        }

        $job = $job_model->get($job_id);

        if (empty($job['status'])) {
            return null;
        }

        $this->setJsSettings('job', $job);

        if ($this->getQuery('process_job') === $job['id'] && $this->isAjax()) {
            $this->outputJson($job_model->process($job));
        }

        return null;
    }
560858
public function process()
    {
        $maxJobs = $this->scopeConfig->getValue('springbot/queue/max_jobs');
        if (!is_numeric($maxJobs)) {
            $maxJobs = 1;
        }

        for ($i = 1; $i <= $maxJobs; $i++) {
            if ($this->runNextJob() === null) {
                return null;
            }
        }
        return true;
    }
277657
public function loadApplicationsForJob($job)
    {
        return $this->createQueryBuilder()
                    ->field("job")->equals(new \MongoId($job->getId()))
                    ->getQuery()
                    ->execute();
    }
589941
public function get(string $name) : JobInterface
    {
        if ($this->has($name)) {
            return $this->getOrMake($name);
        }

        throw new JobException("There is no such job: '$name'");
    }
673153
public function getInstance()
	{
		if (!is_null($this->instance)) {
			return $this->instance;
		}

        $this->instance = $this->getJobFactory()->create($this->payload['class'], $this->getArguments(), $this->queue);
        $this->instance->job = $this;
        return $this->instance;
	}