declare tick or
Closed this issue · 2 comments
GDmac commented
https://github.com/ackintosh/snidel/blob/master/src/Snidel/Fork/Coordinator.php#L152
(From my comment at BernardPHP)
Declare tick should maybe not be used at all, many places on the web it is suggested to use pcntl_signal_dispatch instead.
Inside the drivers, instead of usleep(), could use time_nanosleep, which is interruptable.
pcntl_signal_dispatch();
$nano = time_nanosleep(0, 100000000);
if ($nano === true) {
// slept
} elseif ($nano === false) {
// nanosleep fail
usleep(100000);
} elseif (is_array($nano)) {
// Interrupted by a signal
pcntl_signal_dispatch();
return array(null, null);
}
pcntl_signal_dispatch();
(edit: via GeniusesOfSymfony/WebSocketBundle#125 )
ackintosh commented
Hi @GDmac , thanks for letting me know about that! ✨
I'll update with pcntl_signal_dispatch according to your comment. Please let me know if you would like to address the improvement.
GDmac commented
Nice, however beware,
you have not added the fail-safe,
in case nano-sleep returns false ?