GLib Eventing



I'm developing a cross platform application using Glib to provide
portability.  I've made heavy use of Windows events (i.e. CreateEvent)
in the past - they allow a thread to sleep indefinitely until one of a
group of events is signaled by another thread.  What the best way to do
something similar using Glib?  

 

I see two ways.  The first is to use a GCond with g_cond_timed_wait.
This has two disadvantages - the thread may only wait on a single signal
type, and there's a GMutex involved, which I'm not using for any other
purpose.  The second is to use a GAsyncQueue with
g_async_queue_timed_pop.  This would allow the thread to wait for
multiple event "types" - the contents of the pointer popped of the queue
would indicate what type of "event" was being signaled.

 

It seems GAsyncQueue is the right structure for this purpose - just want
to ensure there's no structures I'm overlooking, or nothing about the
GAsyncQueue which makes it unsuitable for this purpose....




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