Example #1
0
 /**
  * Reserve a job, with a timeout
  *
  * This method blocks while waiting for a job to become available. Once a new job is
  * received, it is instantiated into a BeanQueueJob and returned. Otherwise false.
  *
  * @return BeanQueueJob or false
  */
 public function reserve_with_timeout($in_timeout = 0)
 {
     if (BeanStalk::DEBUG) {
         echo __METHOD__ . "\n";
     }
     $this->safe_send_message("reserve-with-timeout {$in_timeout}");
     $real = $this->safe_read_message();
     $res = $this->check_reply($real, array('/RESERVED (\\d+) (\\d+)/' => self::OPERATION_OK, '/DEADLINE_SOON/' => self::ERROR_DEADLINE_SOON, '/TIMED_OUT/' => self::ERROR_TIMED_OUT), $data);
     if ($res == self::OPERATION_OK) {
         $jid = $data[0];
         $bytes = $data[1];
         $job = $this->safe_read_message($bytes, 0);
         return BeanQueueJob::open($this, $jid, $job);
     }
     return $res;
 }
Example #2
0
 public function DeleteJob()
 {
     if (!is_null($this->job) && BeanQueueJob::check($this->job)) {
         Beanstalk::delete($this->job);
         $this->job = null;
         // Job is no longer valid
     }
 }