AJA NTV2 SDK  17.5.0.1242
NTV2 SDK 17.5.0.1242
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  using std::recursive_timed_mutex;
17  using std::string;
18 #endif
19 
20 #define LOCK_TIME_INFINITE 0xffffffff
21 
22 
23 // forward declarations
24 class AJALockImpl;
25 
31 {
32 public:
33 
41  AJALock(const char* pName = NULL);
42  virtual ~AJALock();
43 
53  virtual AJAStatus Lock(uint32_t timeout = LOCK_TIME_INFINITE);
54 
61  virtual AJAStatus Unlock();
62 
67  virtual inline bool IsValid(void) const
68  {
69  #if defined(AJA_USE_CPLUSPLUS11) && !defined(AJA_BAREMETAL)
70  return mpMutex != nullptr;
71  #else
72  return mpImpl != NULL;
73  #endif
74  }
75 
76  AJALock (const AJALock & inLock);
77  virtual AJALock & operator = (const AJALock & inLock);
78 
79 private:
80 #if defined(AJA_USE_CPLUSPLUS11) && !defined(AJA_BAREMETAL)
81  recursive_timed_mutex* mpMutex={nullptr};
82  string name;
83 #else
84  AJALockImpl* mpImpl;
85 #endif
86 };
87 
92 {
93 public:
94 
100  AJAAutoLock(AJALock* pLock = NULL);
101 
105  virtual ~AJAAutoLock();
106 
107 private:
108 
109  AJALock* mpLock;
110 };
111 
112 
113 #endif // AJA_LOCK_H
LOCK_TIME_INFINITE
#define LOCK_TIME_INFINITE
Definition: lock.h:20
NULL
#define NULL
Definition: ntv2caption608types.h:19
AJALock::IsValid
virtual bool IsValid(void) const
Definition: lock.h:67
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:30
AJAAutoLock
Definition: lock.h:91