lib/Kue/Scheduler.php
function run()
    {
        $now = new DateTime('now');

        $sleep = min(array_map(
            function($entry) use ($now) {
                list($expression, $job) = $entry;

                return $expression->getNextRunDate($now)->getTimestamp();
            },
            $this->entries
        ));

        time_sleep_until($sleep);

        $scheduled = 0;

        foreach ($this->entries as $entry) {
            list($expression, $job) = $entry;

            if ($expression->isDue($now)) {
                $this->queue->push($job);
                $scheduled += 1;
            }
        }

        $this->queue->flush();

        return $scheduled;
    }
function run()
    {
        $now = new DateTime('now');

        $sleep = min(array_map(
            function($entry) use ($now) {
                list($expression, $job) = $entry;

                return $expression->getNextRunDate($now)->getTimestamp();
            },
            $this->entries
        ));

        time_sleep_until($sleep);

        $scheduled = 0;

        foreach ($this->entries as $entry) {
            list($expression, $job) = $entry;

            if ($expression->isDue($now)) {
                $this->queue->push($job);
                $scheduled += 1;
            }
        }

        $this->queue->flush();

        return $scheduled;
    }
Schedules jobs, sleeps until a job has to be scheduled. Returns
when jobs were scheduled.

@return int Number of scheduled jobs.