1
0
mirror of https://github.com/danog/parallel.git synced 2024-11-30 04:39:01 +01:00

Resolve delayed in a finally block

This commit is contained in:
Aaron Piotrowski 2015-12-16 11:13:06 -06:00
parent 351c86da53
commit 8ff3399797

View File

@ -94,16 +94,18 @@ abstract class AbstractWorker implements Worker
$this->idle = false;
$this->activeDelayed = new Delayed();
yield $this->context->send($task);
try {
yield $this->context->send($task);
$result = (yield $this->context->receive());
$result = (yield $this->context->receive());
} finally {
$this->idle = true;
$this->activeDelayed->resolve();
$this->activeDelayed->resolve();
$this->idle = true;
// We're no longer busy at the moment, so dequeue a waiting task.
if (!$this->busyQueue->isEmpty()) {
$this->busyQueue->dequeue()->resolve();
// We're no longer busy at the moment, so dequeue a waiting task.
if (!$this->busyQueue->isEmpty()) {
$this->busyQueue->dequeue()->resolve();
}
}
if ($result instanceof TaskFailure) {