PLCnext API Documentation 23.6.0.37
Mutex.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6#pragma once
8
9// forwards
10namespace Arp { namespace System { namespace Ve
11{
12class IMutexService;
13}}}
14
15namespace Arp { namespace System { namespace Commons { namespace Threading
16{
17
18// Forward declaration for friend class usage.
19class ConditionVariable;
20
25class Mutex
26{
27 friend class ConditionVariable;
28
29public: // construction/destruction
31 Mutex(bool recursive = true);
32
34 Mutex(Mutex&& arg);
35
37 virtual ~Mutex(void);
38
39public: // operations
43 void Lock(void);
44
46 void Unlock(void);
47
50 bool TryLock(void);
51
52private: // deleted methods
53 Mutex(const Mutex& arg) = delete;
54 Mutex& operator=(const Mutex& arg) = delete;
55
56private: // usings/typedefs
57 using IMutexService = Arp::System::Ve::IMutexService;
58
59private: // fields
60 Arp::System::Ve::IMutexService* pMutexService;
61};
62
64// inline methods of class Mutex
65
66}}}} // end of namespace Arp::System::Commons::Threading
Mutual exclusion object to prevent data from concurrent modifications.
Definition: Mutex.hpp:26
Mutex(Mutex &&arg)
Move contructor
void Lock(void)
Tries to acquire the lock.
bool TryLock(void)
Like Lock but returns immediately if the lock is already obtained by another thread.
void Unlock(void)
Releases the lock.
virtual ~Mutex(void)
Destructs this instance and frees all resources.
Mutex(bool recursive=true)
Constructs and initializes an Mutex instance.
@ System
System components used by the System, Device, Plc or Io domains.
Root namespace for the PLCnext API