예제 #1
0
 /**
  * Attempt to find a job from the top of one of the queues for this worker.
  *
  * @return PromiseInterface
  */
 public function reserve()
 {
     $queues = $this->queues();
     if ($queues instanceof PromiseInterface) {
         if ($this->paused) {
             return $queues->then(function () {
                 sleep($this->options['interval']);
             });
         } else {
             return $queues->then(function ($response) {
                 if (empty($response)) {
                     sleep($this->options['interval']);
                     return \React\Promise\resolve();
                 }
                 return Resque::bpop($response, $this->options['interval']);
             });
         }
     } else {
         if ($this->processing <= $this->options['concurrency']) {
             return Resque::bpop($queues, $this->options['interval']);
         } else {
             return \React\Promise\resolve();
         }
     }
 }