Re: Recalculation of timeouts with g_timeout_add



On Fri, May 16, 2008 at 1:20 PM, Mitko Haralanov <mitko qlogic com> wrote:
On Fri, 16 May 2008 09:54:22 +0200
G Hasse <gorhas raditex se> wrote:

Let your callback return FALSE and reregister before the return

Hi, I thought of that but I was sure that there is a better way to do
this without playing games with unregistering and re-registering the
timeout.

I am not sure why the GTK devs decided that re-calculating the timeout
based on the time right after the timeout thread is started is the
right thing to do but it seems very wrong to me.

It isn't a "timeout thread", it just a function that is run in the main loop.
It really isn't a matter of right or wrong, it comes down to the fact
that it had to work one way and it so happens that it works like this.
Depending on your intended usage, the way that subsequent timeouts are
called may or may be what you want.

What if the timeout function takes longer then the timeout itself? You
end up with multiple threads running the timeout function at the same
time.

No, the timeout function will block the main loop until it completes;
there will not be multiple threads running your timeout function.

-D



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