mirror of
https://github.com/amphp/parallel.git
synced 2025-02-21 13:22:44 +01:00
Faster freeing of task memory
This commit is contained in:
parent
aaee76e3da
commit
0e71b18197
@ -37,11 +37,7 @@ class TaskRunner {
|
|||||||
$job = yield $this->channel->receive();
|
$job = yield $this->channel->receive();
|
||||||
|
|
||||||
while ($job instanceof Internal\Job) {
|
while ($job instanceof Internal\Job) {
|
||||||
$task = $job->getTask();
|
call([$job->getTask(), 'run'], $this->environment)->onResolve(function ($exception, $value) use ($job) {
|
||||||
|
|
||||||
$result = call([$task, 'run'], $this->environment);
|
|
||||||
|
|
||||||
$result->onResolve(function ($exception, $value) use ($job) {
|
|
||||||
if ($exception) {
|
if ($exception) {
|
||||||
$result = new Internal\TaskFailure($job->getId(), $exception);
|
$result = new Internal\TaskFailure($job->getId(), $exception);
|
||||||
} else {
|
} else {
|
||||||
@ -51,6 +47,8 @@ class TaskRunner {
|
|||||||
$this->channel->send($result);
|
$this->channel->send($result);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
unset($job); // Free memory from last job.
|
||||||
|
|
||||||
$job = yield $this->channel->receive();
|
$job = yield $this->channel->receive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user