Sets our main struct and passes it to the parent class.
If threads are waiting for cond, all of them are unblocked. If no threads are waiting for cond, this function has no effect. It is good practice to lock the same mutex as the waiting threads while calling this function, though not required.
Get the main Gtk struct
the main Gtk struct as a void*
Initialises a glib.Cond so that it can be used.
If threads are waiting for cond, at least one of them is unblocked. If no threads are waiting for cond, this function has no effect. It is good practice to hold the same lock as the waiting thread while calling this function, though not required.
Atomically releases mutex and waits until cond is signalled. When this function returns, mutex is locked again and owned by the calling thread.
Waits until either cond is signalled or end_time has passed.
the main Gtk struct
The glib.Cond struct is an opaque data structure that represents a condition. Threads can block on a glib.Cond if they find a certain condition to be false. If other threads change the state of this condition they signal the glib.Cond, and that causes the waiting threads to be woken up.
Consider the following example of a shared variable. One or more threads can wait for data to be published to the variable and when another thread publishes the data, it can signal one of the waiting threads to wake up to collect the data.
Here is an example for using GCond to block a thread until a condition is satisfied:
henever 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().
The example shows that use of a condition variable must always be paired with a mutex. Without the use of a mutex, there would be a race between the check of current_data by the while loop in pop_data() and waiting. Specifically, another thread could set current_data after the check, and signal the cond (with nobody waiting on it) before the first thread goes to sleep. glib.Cond is specifically useful for its ability to release the mutex and go to sleep atomically.
It is also important to use the Cond.wait and Cond.waitUntil functions only inside a loop which checks for the condition to be true. See Cond.wait for an explanation of why the condition may not be true even after it returns.
If a glib.Cond is allocated in static storage then it can be used without initialisation. Otherwise, you should call Cond.init on it and Cond.clear when done.
A glib.Cond should only be accessed via the g_cond_ functions.