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

Non-recursive, exclusive mutex. More...

#include <mutex.h>

Public Member Functions

 Mutex ()
 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 the mutex. More...
 

Detailed Description

Non-recursive, exclusive mutex.

Mutexes of this type cannot be locked recursively, that is, multiple times by the same thread with unlocking it in between. Moreover, it cannot be copied or assigned.

See also
RecursiveMutex
Implemented concepts:
Mutex Concept

Constructor & Destructor Documentation

embb::base::Mutex::Mutex ( )

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::Mutex::Lock ( )

Waits until the mutex can be locked and locks it.

Precondition
The mutex is not locked by the current thread.
Postcondition
The mutex is locked
Concurrency
Thread-safe
See also
TryLock(), Unlock()
bool embb::base::Mutex::TryLock ( )

Tries to lock the mutex and returns immediately.

Precondition
The mutex is not locked by the current thread.
Postcondition
If successful, the mutex is locked.
Returns
true if the mutex could be locked, otherwise false.
Concurrency
Thread-safe
See also
Lock(), Unlock()
void embb::base::Mutex::Unlock ( )

Unlocks the mutex.

Precondition
The mutex is locked by the current thread
Postcondition
The mutex is unlocked
Concurrency
Thread-safe
See also
Lock(), TryLock()