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

Re: threading





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

[snip]

> when I trying the following code in gtk:
> 
> 	while(1)
> 	while(gtk_events_pending()) {
> 		gtk_main_iteration();
> 	}
> 
> I noticed that this little gtk application eat up all my cpu's spare
> time!

the sleep(0) in my code prevents it from using all spare cycles.



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