PLCnext API Documentation
22.9.0.33
|
Mutual exclusion object to prevent data from concurrent modifications. More...
#include <Mutex.hpp>
Public Member Functions | |
Mutex (bool recursive=true) | |
Constructs and initializes an Mutex instance. More... | |
Mutex (Mutex &&arg) | |
Move contructor More... | |
virtual | ~Mutex (void) |
Destructs this instance and frees all resources. More... | |
void | Lock (void) |
Tries to acquire the lock. More... | |
void | Unlock (void) |
Releases the lock. More... | |
bool | TryLock (void) |
Like Lock but returns immediately if the lock is already obtained by another thread. More... | |
Friends | |
class | ConditionVariable |
Mutual exclusion object to prevent data from concurrent modifications.
Instances of this class has two states: locked and unlocked. As soon as a call to Lock() returns the calling thread has acquired the lock and every other thread that also calls Lock() is suspended until the first thread calls Unlock(). Thus objects uses instances of this class can prevent their data from concurrent modification from different threads.
Arp::System::Commons::Threading::Mutex::Mutex | ( | bool | recursive = true | ) |
Constructs and initializes an Mutex instance.
Arp::System::Commons::Threading::Mutex::Mutex | ( | Mutex && | arg | ) |
Move contructor
|
virtual |
Destructs this instance and frees all resources.
void Arp::System::Commons::Threading::Mutex::Lock | ( | void | ) |
Tries to acquire the lock.
If the lock is already taken by another thread, the calling thread blocks until the lock becomes available again, i.e. the thread currently obtaining the lock calls Unlock.
bool Arp::System::Commons::Threading::Mutex::TryLock | ( | void | ) |
Like Lock but returns immediately if the lock is already obtained by another thread.
void Arp::System::Commons::Threading::Mutex::Unlock | ( | void | ) |
Releases the lock.