Ooops, forgot to CC the list: On Thu, May 17, 2012 at 1:43 PM, Rick Berger <rckb...@gmail.com> wrote: > In GTK+ 2.20, what is the preferred way to wait while polling a flag in > shared memory every 25 milliseconds in code something like this?
The preferred thing to do is to never use polling for synchronization of processes and threads. Rather, use events and messages to unblock sleeping threads. Instead of running the following loop for instance, you could simply call `read()', the read() call will block when called on a FIFO (named pipe) until data appears on the file descriptor. Cheers, -Tristan > > > gint n; > for( n=10; n && (sharedMemory->flag != 1), n--) { > > > /* wait 25 milliseconds */ > > } > > > if( n == 0 ) { > > g_warning("Timed out while waiting for flag"); > > return 0; > > } > _______________________________________________ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list