mirror of
https://github.com/danog/parallel.git
synced 2024-11-26 12:24:40 +01:00
Use Events::setBlocking() added to parallel extension
This commit is contained in:
parent
7303b8dcf3
commit
2d02d964f4
@ -26,20 +26,16 @@ class ParallelHub extends ProcessHub
|
||||
parent::__construct();
|
||||
|
||||
$events = $this->events = new Events;
|
||||
$this->events->setTimeout(0);
|
||||
$this->events->setBlocking(false);
|
||||
|
||||
$channels = &$this->channels;
|
||||
$this->watcher = Loop::repeat(self::EXIT_CHECK_FREQUENCY, static function () use (&$channels, $events): void {
|
||||
try {
|
||||
while ($event = $events->poll()) {
|
||||
$id = (int) $event->source;
|
||||
\assert(isset($channels[$id]), 'Channel for context ID not found');
|
||||
$channel = $channels[$id];
|
||||
unset($channels[$id]);
|
||||
$channel->close();
|
||||
}
|
||||
} catch (Timeout $exception) {
|
||||
// Ignore poll timeout.
|
||||
while ($event = $events->poll()) {
|
||||
$id = (int) $event->source;
|
||||
\assert(isset($channels[$id]), 'Channel for context ID not found');
|
||||
$channel = $channels[$id];
|
||||
unset($channels[$id]);
|
||||
$channel->close();
|
||||
}
|
||||
});
|
||||
Loop::disable($this->watcher);
|
||||
|
Loading…
Reference in New Issue
Block a user