8000 Merge pull request #179 from CharlotteDunoisLabs/async-dispatch · reactphp/event-loop@c795e50 · GitHub
[go: up one dir, main page]

Skip to content

Commit c795e50

Browse files
authored
Merge pull request #179 from CharlotteDunoisLabs/async-dispatch
Add pcntl async signal dispatching if available
2 parents 1ed8f4b + 4a3e85f commit c795e50

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/StreamSelectLoop.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,20 @@ final class StreamSelectLoop implements LoopInterface
6262
private $writeListeners = array();
6363
private $running;
6464
private $pcntl = false;
65+
private $pcntlActive = false;
6566
private $signals;
6667

6768
public function __construct()
6869
{
6970
$this->futureTickQueue = new FutureTickQueue();
7071
$this->timers = new Timers();
7172
$this->pcntl = \extension_loaded('pcntl');
73+
$this->pcntlActive = $this->pcntl && !\function_exists('pcntl_async_signals');
7274
$this->signals = new SignalsHandler();
75+
76+
if ($this->pcntl && !$this->pcntlActive) {
77+
\pcntl_async_signals(true);
78+
}
7379
}
7480

7581
public function addReadStream($stream, $listener)
@@ -222,7 +228,7 @@ private function waitForStreamActivity($timeout)
222228
$write = $this->writeStreams;
223229

224230
$available = $this->streamSelect($read, $write, $timeout);
225-
if ($this->pcntl) {
231+
if ($this->pcntlActive) {
226232
\pcntl_signal_dispatch();
227233
}
228234
if (false === $available) {

0 commit comments

Comments
 (0)
0