GFC Logo GFC Title Logo
Reference Manual
Main Page  |  Namespace List  |  Alphabetical List  |  Class List  |  File List

GFC::G::StaticRecMutex Struct Reference

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

#include <gfc/glib/mutex.hh>

Inheritance diagram for GFC::G::StaticRecMutex:

GFC::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 GFC_STATIC_REC_MUTEX_INIT. All of the StaticRecMutex methods can be used if G::Thread::init() has not been called.


Member Function Documentation

void GFC::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 GFC::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 GFC::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 GFC::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:
Generated on Tue Aug 24 00:04:58 2004 for GFC-Core by doxygen 1.3.8