Ejemplo n.º 1
0
 public function getNext(Queue $proxies)
 {
     if ($proxies->isEmpty()) {
         return;
     }
     $index = rand(0, $proxies->count() - 1);
     for ($i = $index; $i > 0; --$i) {
         $proxies->dequeue();
     }
     return $proxies->dequeue();
 }
Ejemplo n.º 2
0
 public function getNext(Queue $proxies)
 {
     if ($proxies->isEmpty()) {
         return;
     }
     $available_proxies = $proxies->count();
     //get next position
     for ($i = $this->counter; $i > 0; --$i) {
         $proxies->dequeue();
     }
     //update counter
     $this->counter = ($this->counter + 1) % $available_proxies;
     return $proxies->dequeue();
 }