LRT14  1.0
 All Classes Namespaces Functions Variables Enumerations Enumerator
RhesusTask.h
1 #ifndef RHESUS_RHESUSTASK_H_
2 #define RHESUS_RHESUSTASK_H_
3 
4 #include <map>
5 
6 #include <Task.h>
7 #include "SyncObject.h"
8 
9 using namespace std;
10 
11 namespace Rhesus
12 {
13 namespace Toolkit
14 {
15 namespace Tasks
16 {
17  class RhesusTask
18  {
19  public:
20  static RhesusTask& CreateNew(const char* name, FUNCPTR function, INT32 priority = Task::kDefaultPriority, UINT32 stackSize = 20000);
21  static void Finalize();
22 
23  virtual ~RhesusTask();
24 
25  bool Start(UINT32 arg0 = 0, UINT32 arg1 = 0, UINT32 arg2 = 0, UINT32 arg3 = 0, UINT32 arg4 = 0,
26  UINT32 arg5 = 0, UINT32 arg6 = 0, UINT32 arg7 = 0, UINT32 arg8 = 0);
27 
28  bool Restart();
29  bool Stop();
30 
31  bool IsReady();
32  bool IsSuspended();
33 
34  bool Suspend();
35  bool Resume();
36 
37  bool Verify();
38 
39  void Join();
40 
41  INT32 GetPriority();
42  bool SetPriority(INT32 priority);
43  const char* GetName();
44  INT32 GetID();
45 
46  private:
47  static map<const char*, RhesusTask*> m_tasks;
48 
49  static INT32 intern_taskEntry(UINT32 inst, UINT32 arg0, UINT32 arg1, UINT32 arg2, UINT32 arg3, UINT32 arg4,
50  UINT32 arg5, UINT32 arg6, UINT32 arg7, UINT32 arg8);
51 
52  static void AddTask(RhesusTask* task);
53  static void RemoveTask(const char* name);
54 
55  RhesusTask(const char* name, FUNCPTR function, INT32 priority = Task::kDefaultPriority, UINT32 stackSize = 20000);
56 
57  FUNCPTR m_taskFunc;
58 
59  SyncObject m_taskEndMutex;
60 
61  Task* task();
62 
63  Task* m_task;
64  };
65 }
66 }
67 }
68 
69 #endif