32 |
#include <pthread.h> |
#include <pthread.h> |
33 |
#include <errno.h> |
#include <errno.h> |
34 |
|
|
35 |
/// Callback function for the POSIX thread API |
// Callback functions for the POSIX thread API |
36 |
void* __pthread_launcher(void* thread); |
void* __pthread_launcher(void* thread); |
37 |
|
void __pthread_destructor(void* thread); |
38 |
|
|
39 |
/// Abstract base class for classes that need to run in an own thread. |
/// Abstract base class for classes that need to run in an own thread. |
40 |
class Thread { |
class Thread { |
43 |
virtual ~Thread(); |
virtual ~Thread(); |
44 |
virtual int StartThread(); |
virtual int StartThread(); |
45 |
virtual int StopThread(); |
virtual int StopThread(); |
46 |
|
virtual int SignalStopThread(); |
47 |
virtual bool IsRunning() { return Running; } |
virtual bool IsRunning() { return Running; } |
48 |
virtual int SetSchedulingPriority(); //FIXME: should be private |
virtual int SetSchedulingPriority(); //FIXME: should be private |
49 |
virtual int Main() = 0; ///< This method needs to be implemented by the descendant and is the entry point for the new thread. |
virtual void EnableDestructor(); //FIXME: should be private |
50 |
|
virtual int Destructor(); //FIXME: should be private |
51 |
|
virtual int Main() = 0; ///< This method needs to be implemented by the descendant and is the entry point for the new thread. |
52 |
private: |
private: |
53 |
pthread_t __thread_id; |
pthread_t __thread_id; |
54 |
int PriorityMax; |
pthread_key_t __thread_destructor_key; |
55 |
int PriorityDelta; |
pthread_mutex_t __thread_state_mutex; |
56 |
bool Running; |
pthread_cond_t __thread_exit_condition; |
57 |
bool isRealTime; |
int PriorityMax; |
58 |
|
int PriorityDelta; |
59 |
|
bool Running; |
60 |
|
bool isRealTime; |
61 |
}; |
}; |
62 |
|
|
63 |
#endif // __THREAD_H__ |
#endif // __THREAD_H__ |