Guiliani  Version 2.5 revision 7293 (documentation build 13)
GUIThread.h
1/*
2* Copyright (C) TES Electronic Solutions GmbH,
3* All Rights Reserved.
4* Contact: info@guiliani.de
5*
6* This file is part of the Guiliani HMI framework
7* for the development of graphical user interfaces on embedded systems.
8*/
9
10#ifndef _GUITHREAD__H_
11#define _GUITHREAD__H_
12
13#include "eC_Types.h"
14
16enum ThreadPriority_t
17{
18 GUITHREAD_PRIORITY_IDLE,
19 GUITHREAD_PRIORITY_ABOVE_IDLE,
20 GUITHREAD_PRIORITY_BELOW_LOW,
21 GUITHREAD_PRIORITY_LOW,
22 GUITHREAD_PRIORITY_ABOVE_LOW,
23 GUITHREAD_PRIORITY_BELOW_NORM,
24 GUITHREAD_PRIORITY_NORM,
25 GUITHREAD_PRIORITY_ABOVE_NORM,
26 GUITHREAD_PRIORITY_BELOW_HIGH,
27 GUITHREAD_PRIORITY_HIGH,
28 GUITHREAD_PRIORITY_ABOVE_HIGH,
29 GUITHREAD_PRIORITY_BELOW_CRITICAL,
30 GUITHREAD_PRIORITY_CRITICAL,
31 GUITHREAD_PRIORITY_ABOVE_CRITICAL,
32 GUITHREAD_PRIORITY_BELOW_REALTIME,
33 GUITHREAD_PRIORITY_REALTIME,
34 GUITHREAD_PRIORITY_NOT_SET
35};
36
38
85{
86public:
90 inline void* GetArg() const {return m_pArg;}
91
95 inline void SetArg(void* pArg) {m_pArg = pArg;}
96
98 inline eC_Bool IsRunning() const {return m_bRunning;}
99
101 inline eC_Bool IsShutdownCompleted() const {return m_bShutdownFinishedFlag;}
102
104 inline void* GetThreadId() const {return m_pThreadId;}
105
112 eC_Int Start(void *pArg);
113
143 void Terminate();
144
147 inline void InitShutdown() {m_bRunning = false;}
148
150 void WaitForShutdown();
151
155 void SetPriority(const ThreadPriority_t& ePriority);
156
160 ThreadPriority_t GetPriority();
161
162protected:
166 CGUIThread(const eC_UInt& uiStackSize);
167
169 virtual ~CGUIThread();
170
172 virtual void Setup() {}
173
178 virtual void Execute(void *pArg) =0;
179
183 virtual void Cleanup() {}
184
189 eC_Int MapPriority(const ThreadPriority_t& ePriority);
190
195 ThreadPriority_t MapPriority(const eC_Int& iPriority);
196
199 void *m_pArg;
200 volatile eC_Bool m_bRunning;
201
202private:
205 CGUIThread();
206
207 /* Private copy-constructor. Should not be used.
208 * Dummy declaration with no implementation, just to hide the function.
209 @param kSource Source object.
210 */
211 CGUIThread(const CGUIThread& kSource);
212
213 /* Private operator= method. Should not be used.
214 * Dummy declaration with no implementation, just to hide the function.
215 @param kSource Source object.
216 @return this object.
217 */
218 CGUIThread& operator=(const CGUIThread& kSource);
219
221 void Run();
222
226 static void* EntryPoint(void *pThis);
227
229 void Init();
230
232 void DeInit();
233
234private:
236 void *m_pHandle;
237
239 eC_Bool m_bShutdownFinishedFlag;
240};
241#endif
This is the base class for Guiliani threads.
Definition: GUIThread.h:85
void * GetThreadId() const
Definition: GUIThread.h:104
void WaitForShutdown()
Definition: GUIThreadDummy.cpp:53
CGUIThread(const eC_UInt &uiStackSize)
void * GetArg() const
Definition: GUIThread.h:90
void * m_pArg
Pointer to arguments to be passed to the thread.
Definition: GUIThread.h:199
eC_Int MapPriority(const ThreadPriority_t &ePriority)
Definition: GUIThreadDummy.cpp:43
eC_Int Start(void *pArg)
Definition: GUIThreadDummy.cpp:25
void InitShutdown()
Definition: GUIThread.h:147
virtual void Setup()
Definition: GUIThread.h:172
void SetPriority(const ThreadPriority_t &ePriority)
Definition: GUIThreadDummy.cpp:34
void Terminate()
Definition: GUIThreadDummy.cpp:30
virtual ~CGUIThread()
eC_Bool IsRunning() const
Definition: GUIThread.h:98
void * m_pThreadId
This thread's unique ID.
Definition: GUIThread.h:198
eC_Bool IsShutdownCompleted() const
Definition: GUIThread.h:101
ThreadPriority_t GetPriority()
Definition: GUIThreadDummy.cpp:38
void SetArg(void *pArg)
Definition: GUIThread.h:95
eC_UInt m_uiStackSize
Size for this thread's stack.
Definition: GUIThread.h:197
virtual void Execute(void *pArg)=0
virtual void Cleanup()
Definition: GUIThread.h:183
volatile eC_Bool m_bRunning
Whether this thread is currently running.
Definition: GUIThread.h:200