Skip to content

Commit 8d05ffd

Browse files
authored
Merge pull request #158 from WyriHaximus-secret-labs/queue-drain-simplyfied
Simplify queue draining while retaining functionality
2 parents 6537ab2 + f5343a3 commit 8d05ffd

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

src/Internal/Queue.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,10 @@ public function enqueue(callable $task): void
1919
private function drain(): void
2020
{
2121
for ($i = \key($this->queue); isset($this->queue[$i]); $i++) {
22-
$task = $this->queue[$i];
23-
24-
$exception = null;
25-
2622
try {
27-
$task();
28-
} catch (\Throwable $exception) {
29-
}
30-
31-
unset($this->queue[$i]);
32-
33-
if ($exception) {
34-
throw $exception;
23+
($this->queue[$i])();
24+
} finally {
25+
unset($this->queue[$i]);
3526
}
3627
}
3728

0 commit comments

Comments
 (0)