Reference Manual
Inti Logo
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

Inti::G::StaticRecMutex Struct Reference

A compile-time GStaticRecMutex C++ wrapper interface. More...

#include <inti/glib/mutex.h>

Inheritance diagram for Inti::G::StaticRecMutex:

Inti::G::RecMutex List of all members.

Public Member Functions

Constructors
Accessors
Methods

Detailed Description

A compile-time GStaticRecMutex C++ wrapper interface.

A StaticRecMutex works like a StaticMutex, but it can be locked multiple times by one thread If you enter it n times, however, you have to unlock it n times again to let other threads lock it. An exception is the function unlock_full(), that allows you to unlock a StaticRecMutex completely returning the depth, i.e. the number of times this mutex was locked. The depth can later be used to restore the state by calling lock().

A StaticRecMutex can be statically initialized with the value INTI_STATIC_REC_MUTEX_INIT. All of the StaticRecMutex methods can be used if G::Thread::init() has not been called.


Member Function Documentation

void Inti::G::StaticRecMutex::lock unsigned int  depth = 1  ) 
 

Locks the mutex.

Parameters:
depth The number of times the mutex has to be unlocked to be completely unlocked.

If the mutex is already locked by another thread, the current thread will block until mutex is unlocked by the other thread. If mutex is already locked by the calling thread, this functions increases the depth of mutex depth times and returns. The default depth is one.

bool Inti::G::StaticRecMutex::trylock  ) 
 

Tries to lock the mutex.

Returns:
true if the mutex could be locked.

If mutex is already locked by another thread, it immediately returns false. Otherwise it locks mutex and returns true. If mutex is already locked by the calling thread, this functions increases the depth of mutex by one and immediately returns true.

void Inti::G::StaticRecMutex::unlock  ) 
 

Unlocks the mutex one level.

Other threads can only lock the mutex when it has been unlocked as many times, as it had been locked before. If mutex is completely unlocked and another thread is blocked in a lock() call for mutex, it will be woken and can lock mutex itself.

unsigned int Inti::G::StaticRecMutex::unlock_full  ) 
 

Unlocks the mutex completely.

Other threads can only lock mutex when it has been unlocked as many times, as it had been locked before. If mutex is completely unlocked and another thread is blocked in a lock() call for mutex, it will be woken and can lock mutex itself.


The documentation for this struct was generated from the following file: Main Page - Footer


Generated on Sun Sep 14 20:08:09 2003 for Inti by doxygen 1.3.2 written by Dimitri van Heesch, © 1997-2002