Re: How do I add a precise timeout function
- From: Paul Davis <pbd op net>
- To: "Ed Woods" <ecwoods erols com>
- Cc: gtk-list gnome org
- Subject: Re: How do I add a precise timeout function
- Date: Sun, 15 Sep 2002 07:46:26 -0400
>I have to perform periodic tasks, 2 to 5 times a sec, that are called =
>with an accuracy of +- 0.05 sec. I have tried gtk_timeout_add with the =
>appropriate values, but the callback timing is heavily dependent on =
>things beyond my control. I am running several threads using g_threads =
>which are handling socket traffic. Is there anyway to have more control =
>over the timing of the callbacks in gtk? I am going to try increasing =
>the priority of the main thread as a first attempt.
1) please turn off the option in your email program that sends mail
as both plain text and HTML-formatted text.
2) you will not be able to make this work with your current
design. you cannot, in general, use the main event loop of a GUI
to get accurate timeout scheduling. instead, create a separate
thread and use one of the many POSIX sleep functions (usleep, for
example). if the thread has to do GUI stuff, connect it to
the GUI thread with a pipe, and send a request through the pipe.
otherwise, your periodic thread will have to acquire the gdk
thread lock, which may mess up timing for the very same reasons
that its messed up now (too much bursty work being done from
the event loop).
] [Thread Prev