Top |
GdaLockable is implemented by GdaConnection, GdaHolder, GdaSqlParser, GdaVconnectionDataModel, GdaVconnectionHub and GdaVirtualConnection.
This interface is implemented by objects which are thread safe (ie. can be used by several threads at
the same time). Before using an object from a thread, one has to call gda_lockable_lock()
or
gda_lockable_trylock()
and call gda_lockable_unlock()
when the object is not used anymore.
void
gda_lockable_lock (GdaLockable *lockable
);
Locks lockable
. If it is already locked by another thread, the current thread will block until it 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()
, this method recursive, which means a thread can lock lockable
several times
(and has to unlock it as many times to actually unlock it).
gboolean
gda_lockable_trylock (GdaLockable *lockable
);
Tries to lock lockable
. If it is already locked by another thread, then it immediately returns FALSE, otherwise
it locks lockable
.
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()
, this method recursive, which means a thread can lock lockable
several times
(and has to unlock it as many times to actually unlock it).
void
gda_lockable_unlock (GdaLockable *lockable
);
Unlocks lockable
. This method should not be called if the current does not already holds a lock on lockable
(having
used gda_lockable_lock()
or gda_lockable_trylock()
).
This function can be used even if g_thread_init()
has not yet been called, and, in that case, will do nothing.