Пример #1
0
 /**
  * Run the queue
  *
  * @return \Generator
  */
 public function __invoke()
 {
     while (!$this->queue->isEmpty()) {
         usleep(self::SLEEP_MICRO_SECONDS);
         $pending = $this->getPending();
         if ($pending->count() && $this->getRunning()->count() < $this->limit) {
             (yield $pending->shift());
         } else {
             (yield new NullProcess());
         }
         $this->clearCompleted();
     }
 }
 /**
  * Test collection empty method
  *
  * @return void
  */
 public function testIsEmpty()
 {
     $this->assertFalse($this->collection->isEmpty());
     $this->collection->clear();
     $this->assertTrue($this->collection->isEmpty());
 }