Esempio n. 1
0
 /**
  * Returns a job and locks it but doesn't deletes it from the DB.
  * 
  * @param array $jobClasses optional list of job types I'd like to receive.
  * @param bool $randomizeJobList Whether to shuffle job list before trying to aquire a lock.
  * @return ymcJobQueueJob
  */
 public function pop($jobClasses = array(), $randomizeJobList = true)
 {
     $job = $this->storage->pop($jobClasses, $randomizeJobList);
     if (!$job) {
         return NULL;
     }
     return $this->arrayToJob($job);
 }
 public function testPushAndPop()
 {
     $queue = new QueueStorage();
     $queue->push(1);
     $queue->push(2);
     $queue->push(3);
     $this->assertEquals(1, $queue->pop());
     $this->assertEquals(2, $queue->pop());
     $this->assertEquals(3, $queue->pop());
 }