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:
parent
0b16820ca8
commit
5a36a60651
@ -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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user