1
0
mirror of https://github.com/danog/parallel.git synced 2024-11-26 20:34:40 +01:00

Delay call to close

This commit is contained in:
Aaron Piotrowski 2017-06-01 11:15:03 -05:00
parent 0b16820ca8
commit 5a36a60651

View File

@ -151,9 +151,13 @@ class Thread implements Strand {
$this->channel = new ChannelledSocket($channel, $channel); $this->channel = new ChannelledSocket($channel, $channel);
$this->watcher = Loop::repeat(self::EXIT_CHECK_FREQUENCY, function () { $this->watcher = Loop::repeat(self::EXIT_CHECK_FREQUENCY, function ($watcher) {
if (!$this->thread->isRunning()) { if (!$this->thread->isRunning()) {
$this->channel->close(); // Delay call to close to avoid race condition between thread exiting and data becoming available.
Loop::delay(self::EXIT_CHECK_FREQUENCY, function () {
$this->close();
});
Loop::disable($watcher);
} }
}); });