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

Re: threading




in my multithreaded app, rather than call gtk_main(), i use the following
code:

while(1)
 {
   pthread_mutex_lock(draw_mutex);
   while(gtk_events_pending())
    {
      gtk_main_iteration();
    }
   pthread_mutex_unlock(draw_mutex);
   sleep(0);
 }

and the other threads all call pthread_mutex_lock(draw_mutex) before any
gtk functions, and pthread_mutex_unlock(draw_mutex) afterward.  the main
thing to watch out for is having one of your callback functions call
pthread_mutex_lock(draw_mutex) because the callbacks are executed inside
of gtk_main_iteration and the mutex is therefore already locked.




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