The GCond struct is an opaque data structure that represents a
condition. Threads can block on a GCond if they find a certain
condition to be false. If other threads change the state of this
condition they signal the GCond, and that causes the waiting
threads to be woken up.
Whenever a thread calls pop_data() now, it will
wait until current_data is non-NULL, i.e. until some other thread
has called push_data().
Note
It is important to use the g_cond_wait() and
g_cond_timed_wait() functions only inside a loop which checks for the
condition to be true. It is not guaranteed that the waiting thread
will find the condition fulfilled after it wakes up, even if the
signaling thread left the condition in that state: another thread may
have altered the condition before the waiting thread got the chance
to be woken up, even if the condition itself is protected by a
GMutex, like above.
A GCond should only be accessed via the following functions.
Note
All of the g_cond_* functions are
actually macros. Apart from taking their addresses, you can however
use them as if they were functions.
The GCond struct is an opaque data structure that represents a condition. Threads can block on a GCond if they find a certain condition to be false. If other threads change the state of this condition they signal the GCond, and that causes the waiting threads to be woken up. Whenever a thread calls pop_data() now, it will wait until current_data is non-NULL, i.e. until some other thread has called push_data(). Note It is important to use the g_cond_wait() and g_cond_timed_wait() functions only inside a loop which checks for the condition to be true. It is not guaranteed that the waiting thread will find the condition fulfilled after it wakes up, even if the signaling thread left the condition in that state: another thread may have altered the condition before the waiting thread got the chance to be woken up, even if the condition itself is protected by a GMutex, like above. A GCond should only be accessed via the following functions. Note All of the g_cond_* functions are actually macros. Apart from taking their addresses, you can however use them as if they were functions.