Allow GSource timeout precision below 1 millisecond
Currently, we have code for GMainContext
that will try to take the lower of the *timeout * 1000
param to (GSourceFuncs.prepare()
and g_source_get_ready_time())
+ 999/1000
. The reason for the + 999
is stated that if we get to 0 we'll spin, which is of course, true.
However, on Linux we do have another option. We could use a timerfd
and then add that to the poll()
FDs similar to what we do with the GWakeup
eventfd
/pipe
. Then use timerfd_settime()
which takes a struct itimerspec
for nanoseconds and supports CLOCK_MONOTONIC
.
That may further help situations like ClutterFrameClock
which I regularly see is dispatched late on Sysprof profiles.
Edited by Christian Hergert