![]() |
![]() |
![]() |
GNOME Data Access 4.0 manual | ![]() |
---|---|---|---|---|
GdaMutex; GdaMutex* gda_mutex_new (void); void gda_mutex_lock (GdaMutex *mutex); gboolean gda_mutex_trylock (GdaMutex *mutex); void gda_mutex_unlock (GdaMutex *mutex); void gda_mutex_free (GdaMutex *mutex);
GdaMutex implements a recursive mutex (unlike the GMutex implementation which offers no guarantee about recursiveness). A recursive mutex is a mutex which can be locked several times by the same thread (and needs to be unlocked the same number of times before another thread can lock it).
A GdaMutex can safely be used even in a non multi-threaded environment in which case it does nothing.
GdaMutex* gda_mutex_new (void);
Creates a new GdaMutex.
Note: Unlike g_mutex_new(), this function will return NULL if g_thread_init() has not been called yet.
Returns : | a new GdaMutex |
void gda_mutex_lock (GdaMutex *mutex);
Locks m. If m is already locked by another thread, the current thread will block until m is unlocked by the other thread.
This function can be used even if g_thread_init() has not yet been called, and, in that case, will do nothing.
Note: unlike g_mutex_lock(), the GdaMutex is recursive, which means a thread can lock it several times (and has to unlock it as many times to actually unlock it).
mutex : |
gboolean gda_mutex_trylock (GdaMutex *mutex);
mutex : | |
Returns : | TRUE, if m could be locked. |
void gda_mutex_unlock (GdaMutex *mutex);
Unlocks m. If another thread is blocked in a gda_mutex_lock() call for m, it will be woken and can lock m itself. This function can be used even if g_thread_init() has not yet been called, and, in that case, will do nothing.
mutex : |