Пример #1
0
 /**
  * {@inheritDoc}
  */
 public function addQueue(QueueInterface $queue)
 {
     if (isset($this->queues[$queue->getName()])) {
         throw new QueueException('Queue already exists');
     }
     $this->queues[$queue->getName()] = $queue;
 }
Пример #2
0
 /**
  * Process the queue.
  *
  * @param string $queueName
  * @param callable $callback {
  *      Process item from queue
  *      @param array $item
  *  }
  * @return array Items
  */
 protected function processItems($queueName, $callback = null)
 {
     $end = time() + $this->processingTimeLimit;
     $items = [];
     while (time() < $end && ($item = $this->_queue->pop($queueName))) {
         $items[$item['id']] = $item;
         if (is_callable($callback)) {
             call_user_func($callback, $item);
         }
         $this->_queue->delete($item);
     }
     return $items;
 }