AJA NTV2 SDK  17.5.0.1492
NTV2 SDK 17.5.0.1492
lock.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
8 #ifndef AJA_LOCK_H
9 #define AJA_LOCK_H
10 
11 #include "ajabase/common/public.h"
12 #include <assert.h>
13 #if defined(AJA_USE_CPLUSPLUS11) && !defined(AJA_BAREMETAL)
14  #include <mutex>
15  #include <string>
16 #endif
17 
18 #define LOCK_TIME_INFINITE 0xffffffff
19 
20 
21 // forward declarations
22 class AJALockImpl;
23 
29 {
30 public:
31 
39  AJALock(const char* pName = NULL);
40  virtual ~AJALock();
41 
51  virtual AJAStatus Lock(uint32_t timeout = LOCK_TIME_INFINITE);
52 
59  virtual AJAStatus Unlock();
60 
65  virtual inline bool IsValid(void) const
66  {
67  #if defined(AJA_USE_CPLUSPLUS11) && !defined(AJA_BAREMETAL)
68  return mpMutex != nullptr;
69  #else
70  return mpImpl != NULL;
71  #endif
72  }
73 
74  AJALock (const AJALock & inLock);
75  virtual AJALock & operator = (const AJALock & inLock);
76 
77 private:
78 #if defined(AJA_USE_CPLUSPLUS11) && !defined(AJA_BAREMETAL)
79  std::recursive_timed_mutex* mpMutex={nullptr};
80  std::string mName;
81 #else
82  AJALockImpl* mpImpl;
83 #endif
84 };
85 
90 {
91 public:
92 
98  AJAAutoLock(AJALock* pLock = NULL);
99 
103  virtual ~AJAAutoLock();
104 
105 private:
106 
107  AJALock* mpLock;
108 };
109 
110 #endif // AJA_LOCK_H
LOCK_TIME_INFINITE
#define LOCK_TIME_INFINITE
Definition: lock.h:18
NULL
#define NULL
Definition: ntv2caption608types.h:19
AJALock::IsValid
virtual bool IsValid(void) const
Definition: lock.h:65
AJA_EXPORT
#define AJA_EXPORT
Definition: export.h:34
AJALockImpl
Definition: lockimpl.h:18
public.h
Master header for the ajabase library.
AJAStatus
AJAStatus
Definition: types.h:378
AJALock
Definition: lock.h:28
AJAAutoLock
Definition: lock.h:89