AJA NTV2 SDK  18.0.0.2122
NTV2 SDK 18.0.0.2122
threadimpl.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: MIT */
8 #ifndef AJA_THREAD_IMPL_H
9 #define AJA_THREAD_IMPL_H
10 
11 #include <pthread.h>
12 #include "ajabase/system/system.h"
13 #include "ajabase/common/common.h"
14 #include "ajabase/system/thread.h"
15 #include "ajabase/system/lock.h"
16 
17 
18 class AJAThreadImpl
19 {
20 public:
21 
22  AJAThreadImpl(AJAThread* pThreadContext);
23  virtual ~AJAThreadImpl();
24 
25  AJAStatus Start();
26 
27  AJAStatus Stop(uint32_t timeout = 0xffffffff);
28 
29  AJAStatus Kill(uint32_t exitCode);
30 
31  bool Active();
32  bool IsCurrentThread();
33 
34  AJAStatus SetPriority(AJAThreadPriority threadPriority);
35  AJAStatus GetPriority(AJAThreadPriority* pThreadPriority);
36 
37  AJAStatus SetRealTime(AJAThreadRealTimePolicy policy, int priority);
38 
39  AJAStatus Attach(AJAThreadFunction* pThreadFunction, void* pUserContext);
40  AJAStatus SetThreadName(const char *name);
41 
42  static uint64_t GetThreadId();
43  static void* ThreadProcStatic(void* pThreadImplContext);
44 
45 public:
47  pthread_t mThread;
48  pid_t mTid;
50  AJAThreadFunction* mThreadFunc;
51  void* mpUserContext;
52  AJALock mLock;
53 
54  bool mThreadStarted;
55  pthread_mutex_t mStartMutex;
56  pthread_cond_t mStartCond;
57 
58  bool mTerminate;
59  bool mExiting;
60  pthread_mutex_t mExitMutex;
61  pthread_cond_t mExitCond;
62 };
63 
64 #endif // AJA_THREAD_IMPL_H
65 
Declares the AJALock class.
void * mpUserContext
Definition: threadimpl.h:51
AJAStatus Start()
Definition: threadimpl.cpp:116
AJAThreadPriority
Definition: thread.h:39
AJAStatus
Definition: types.h:380
pthread_cond_t mStartCond
Definition: threadimpl.h:56
bool mThreadStarted
Definition: threadimpl.h:54
bool mTerminate
Definition: threadimpl.h:58
static uint64_t GetThreadId()
Definition: threadimpl.cpp:685
Definition: lock.h:28
AJAStatus Attach(AJAThreadFunction *pThreadFunction, void *pUserContext)
Definition: threadimpl.cpp:566
pthread_mutex_t mStartMutex
Definition: threadimpl.h:55
bool IsCurrentThread()
Definition: threadimpl.cpp:406
AJAThreadPriority mPriority
Definition: threadimpl.h:49
AJAThreadRealTimePolicy
Definition: thread.h:50
pthread_mutex_t mExitMutex
Definition: threadimpl.h:60
Declares the AJAThread class.
virtual ~AJAThreadImpl()
Definition: threadimpl.cpp:84
AJALock mLock
Definition: threadimpl.h:52
AJAThreadFunction * mThreadFunc
Definition: threadimpl.h:50
pthread_cond_t mExitCond
Definition: threadimpl.h:61
AJAThreadImpl(AJAThread *pThreadContext)
Definition: threadimpl.cpp:45
AJAStatus GetPriority(AJAThreadPriority *pThreadPriority)
Definition: threadimpl.cpp:504
System specific functions.
AJAThread * mpThreadContext
Definition: threadimpl.h:46
Private include file for all ajabase sources.
AJAStatus SetPriority(AJAThreadPriority threadPriority)
Definition: threadimpl.cpp:425
AJAStatus Kill(uint32_t exitCode)
Definition: threadimpl.cpp:332
static void * ThreadProcStatic(void *pThreadImplContext)
Definition: threadimpl.cpp:581
AJAStatus SetThreadName(const char *name)
Definition: threadimpl.cpp:672
AJAStatus SetRealTime(AJAThreadRealTimePolicy policy, int priority)
Definition: threadimpl.cpp:522
AJAStatus Stop(uint32_t timeout=0xffffffff)
Definition: threadimpl.cpp:208
pthread_t mThread
Definition: threadimpl.h:47