From cc6f1c3846a77f42c3d5cab013dd012bab2a682a Mon Sep 17 00:00:00 2001 From: Jan Sorgalla Date: Mon, 13 Jul 2015 10:33:41 +0200 Subject: [PATCH] Simplify queue draining code --- src/Queue/SynchronousQueue.php | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/src/Queue/SynchronousQueue.php b/src/Queue/SynchronousQueue.php index 34c0842e..b2d42e9f 100644 --- a/src/Queue/SynchronousQueue.php +++ b/src/Queue/SynchronousQueue.php @@ -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 = []; } }