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

gtk_timeout_add



Hi,
	I'd like to apologize for contradicting Iain about
while(gtk_events_pending())gtk_main_iteration();
Actually, it should work for the timer.  It looks like glib will set off
timers if enough time has elapsed for them to go off even if it doesn't
sleep in its select() call.  Note that you will have to call this at
regular intervals inside of your working functions to have a good chance
of the timer being called at least close to on time.
	However, to get the timeouts to happen reliably, you will probably
have to set off some sort of timer function that is done by the system
(e.g. setitimer).  Now, I don't know how well gtk responds to getting
interrupted by timers.  I.e. if you are in the middle of one gtk call and
then get interrupted by a timer signal and then start doing other gtk
calls.  You may be best off to start up a new thread that sets the timer
and installs a signal handler (note: using pthreads every thread will use
the same signal handler code, though each thread gets its own signals) for
SIGALRM.  Then put the display code in that thread.  Make sure to use Gtk+
in multi-threaded mode (basically two things, put g_thread_init() before
your gtk_main() call and then put gdk_threads_enter() and
gdk_threads_leave() around all of your gtk or gdk calls).
	The data will be a problem.  If you are doing something like image
processing, you will have to either use fine-grained locking which can be
a bit of a pain, or use large-grained locking and then just don't display
anything while it is being worked on and don't work on anything while it
is being displayed.
	What application are you writing?
	-Chris

-- 
lansdoct@cs.alfred.edu
"If I had had more time I would have not written you at all." - Pascal
Linux Programs: http://cs.alfred.edu/~lansdoct/linux/
Linux - Get there. Today.
Evil Overlord Quote of the Day:
150.I will provide funding and research to develop tactical and strategic
weapons covering a full range of needs so my choices are not limited to
"hand to hand combat with swords" and "blow up the planet".






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