Embedded Multicore Building Blocks V1.0.0
Public Member Functions | List of all members
embb::base::RecursiveMutex Class Reference

Recursive, exclusive mutex. More...

#include <mutex.h>

Public Member Functions

 RecursiveMutex ()
 Creates a mutex which is in unlocked state. More...
 
void Lock ()
 Waits until the mutex can be locked and locks it. More...
 
bool TryLock ()
 Tries to lock the mutex and returns immediately. More...
 
void Unlock ()
 Unlocks a locked mutex. More...
 

Detailed Description

Recursive, exclusive mutex.

Mutexes of this type can be locked recursively, that is, multiple times by the same thread without unlocking it in between. It is unlocked only, if the number of unlock operations has reached the number of previous lock operations by the same thread. It cannot be copied or assigned.

See also
Mutex
Implemented concepts:
Mutex Concept

Constructor & Destructor Documentation

embb::base::RecursiveMutex::RecursiveMutex ( )

Creates a mutex which is in unlocked state.

Dynamic memory allocation
Potentially allocates dynamic memory
Concurrency
Not thread-safe

Member Function Documentation

void embb::base::RecursiveMutex::Lock ( )

Waits until the mutex can be locked and locks it.

Postcondition
The mutex is locked
Concurrency
Thread-safe
See also
TryLock(), Unlock()
bool embb::base::RecursiveMutex::TryLock ( )

Tries to lock the mutex and returns immediately.

Postcondition
If successful, the given mutex is locked.
Returns
true if the mutex could be locked, otherwise false.
Concurrency
Thread-safe
See also
Lock(), Unlock()
void embb::base::RecursiveMutex::Unlock ( )

Unlocks a locked mutex.

Precondition
The mutex is locked by the current thread.
Postcondition
The mutex is unlocked if the number of unlock operations has reached the number of lock operations.
Concurrency
Thread-safe
See also
Lock(), TryLock()