Xfce Foundation Classes
Main Page  | IndexNamespace List  |  Alphabetical List  |  Class List  |  File List


Xfc::G::StaticRecMutex Struct Reference

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

#include <xfc/glib/mutex.hh>

Inheritance diagram for Xfc::G::StaticRecMutex:

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


Member Function Documentation

void Xfc::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 Xfc::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 Xfc::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 Xfc::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: Xfce Foundation Classes
Copyright © 2004-2005 The XFC Development Team XFC 4.3