PLCnext API Documentation 25.0.2.69
Mutex.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include "Arp/System/Commons/Threading/LockGuard.hpp"
9
10// forwards
11namespace Arp { namespace System { namespace Ve
12{
13class IMutexService;
14}}}
15
16namespace Arp { namespace System { namespace Commons { namespace Threading
17{
18
19// Forward declaration for friend class usage.
20class ConditionVariable;
21
26class Mutex
27{
28 friend class ConditionVariable;
29
30public: // usings
32
33public: // construction/destruction
34 Mutex(bool recursive = true);
35 Mutex(Mutex&& arg);
36 virtual ~Mutex(void);
37
38public: // operations
39 void Lock(void);
40 void Unlock(void);
41 bool TryLock(void);
42
43private: // deleted methods
44 Mutex(const Mutex& arg) = delete;
45 Mutex& operator=(const Mutex& arg) = delete;
46
47private: // usings/typedefs
48 using IMutexService = Arp::System::Ve::IMutexService;
49
50private: // fields
51 Arp::System::Ve::IMutexService* pMutexService;
52};
53
54}}}} // end of namespace Arp::System::Commons::Threading
Condition variables can be used to synchronize between multiple threads
Definition: ConditionVariable.hpp:27
Simple lock guard, acquiring lock on construction and release it on destruction.
Definition: LockGuard.hpp:17
Mutual exclusion object to prevent data from concurrent modifications.
Definition: Mutex.hpp:27
void Lock(void)
Tries to acquire the lock.
Definition: Mutex.cpp:49
bool TryLock(void)
Like Lock but returns immediately if the lock is already obtained by another thread.
Definition: Mutex.cpp:62
void Unlock(void)
Releases the lock.
Definition: Mutex.cpp:55
virtual ~Mutex(void)
Destructs this instance and frees all resources.
Definition: Mutex.cpp:37
Mutex(bool recursive=true)
Constructs and initializes an Mutex instance.
Definition: Mutex.cpp:17
Root namespace for the PLCnext API