Skip to content

Commit

Permalink
Simplify queue draining code
Browse files Browse the repository at this point in the history
  • Loading branch information
jsor committed Jul 13, 2015
1 parent e855942 commit cc6f1c3
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions src/Queue/SynchronousQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,9 @@ public function enqueue(callable $task)

private function drain()
{
for ($i = key($this->queue); isset($this->queue[$i]); $i++) {
$task = $this->queue[$i];

$exception = null;

try {
$task();
} catch (\Exception $exception) {
}

unset($this->queue[$i]);

if ($exception) {
throw $exception;
}
/** @var callable $task */
while ($task = array_shift($this->queue)) {
$task();
}

$this->queue = [];
}
}

0 comments on commit cc6f1c3

Please sign in to comment.