Re: g_timeout_add(0, ...)



    >> Is it valid to call g_timeout_add with an interval of 0?  If so, does
    >> it have well-defined semantics?  Might it recognize the 0ms interval
    >> and call the handler immediately or will it guarantee that we at
    >> least return to the main loop first?

    Tristan> I think what you want to use is g_idle_add().

No, not in this case.  Ideally, I would like to call my callback
immediately, but for various reasons the caller isn't ready for it yet.  I
just want to wait as little time as possible, to let the caller get its
ducks in a row.  I don't want to wait an indefinite amount of time, as the
likelihood that other events arrive which are then processed out of order
increases.

I found empirically that an interval of 0ms is valid, and by looking at the
source for g_timeout_add I can see that 0 isn't treated specially.  I'm
having a hard time figuring out the first possible time that callback might
occur.  Does the main loop get control first or not?

Thanks,

-- 
Skip Montanaro - skip pobox com - http://smontanaro.dyndns.org/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]