On 20 Aug 2013, at 08:19, Wenchao Xia wrote: > Thanks for the explanation. It seems *timeout is always set > to -1 before calling GSource's prepare(), so > "*timeout = qemu_soonest_timeout(*timeout, 10);" > will always get *timeout = 10, so this call can be saved.
I believe that's incorrect too. glib *currently* calls the API that way, but there's nothing to say a future or past glub couldn't call each g_source with the same timeout pointer, with each g_source adjusting the timeout downwards. Or (for instance) call it with 0 for a non-blocking prepare. Therefore the implemented way is safer (only reducing the timeout). -- Alex Bligh