Properly round event timeout for the epoll driver.
Avoids continuous 0 msec timeouts just before timers expire.
This commit is contained in:
parent
80df8e1ce8
commit
96a8c95b81
|
@ -34,11 +34,12 @@ final class EpollEventDriver : PosixEventDriver {
|
|||
import std.algorithm : min;
|
||||
//assert(Fiber.getThis() is null, "processEvents may not be called from within a fiber!");
|
||||
|
||||
auto ts = timeout.toTimeVal;
|
||||
|
||||
//print("wait %s", m_events.length);
|
||||
auto ret = epoll_wait(m_epoll, m_events.ptr, cast(int)m_events.length, timeout == Duration.max ? -1 : cast(int)min(timeout.total!"msecs", int.max));
|
||||
//print("wait done %s", ret);
|
||||
long tomsec;
|
||||
if (timeout == Duration.max) tomsec = long.max;
|
||||
else tomsec = (timeout.total!"hnsecs" + 9999) / 10_000;
|
||||
auto ret = epoll_wait(m_epoll, m_events.ptr, cast(int)m_events.length, tomsec > int.max ? -1 : cast(int)tomsec);
|
||||
print("wait done %s", ret);
|
||||
|
||||
if (ret > 0) {
|
||||
foreach (ref evt; m_events[0 .. ret]) {
|
||||
|
|
Loading…
Reference in a new issue