Working blocking list pop :)

This commit is contained in:
Ruud Kamphuis 2013-03-13 12:41:32 +01:00
parent b8f98eecd2
commit 86ae77811d
14 changed files with 604 additions and 73 deletions

View file

@ -91,21 +91,20 @@ class Resque_Job
}
/**
* Find the next available job from the specified queue and return an
* instance of Resque_Job for it.
* Find the next available job from the specified queues using blocking list pop
* and return an instance of Resque_Job for it.
*
* @param string $queue The name of the queue to check for a job in.
* @param array $queues
* @param int $timeout
* @return null|object Null when there aren't any waiting jobs, instance of Resque_Job when a job was found.
*/
public static function reserveBlocking($queues, $interval = null)
public static function reserveBlocking(array $queues, $timeout = null)
{
$payload = Resque::blpop($queues, $interval);
$payload = Resque::blpop($queues, $timeout);
if(!is_array($payload)) {
return false;
}
var_dump($payload);
return new Resque_Job($payload->queue, $payload);
}