Faster freeing of task memory

This commit is contained in:
Aaron Piotrowski 2017-11-10 10:32:01 -06:00
parent aaee76e3da
commit 0e71b18197
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB

View File

@ -37,11 +37,7 @@ class TaskRunner {
$job = yield $this->channel->receive();
while ($job instanceof Internal\Job) {
$task = $job->getTask();
$result = call([$task, 'run'], $this->environment);
$result->onResolve(function ($exception, $value) use ($job) {
call([$job->getTask(), 'run'], $this->environment)->onResolve(function ($exception, $value) use ($job) {
if ($exception) {
$result = new Internal\TaskFailure($job->getId(), $exception);
} else {
@ -51,6 +47,8 @@ class TaskRunner {
$this->channel->send($result);
});
unset($job); // Free memory from last job.
$job = yield $this->channel->receive();
}