CMSDK  2.0.1
MemoryQueues.h
1 #if !defined(_MEMORYQUEUES_H_)
2 #define _MEMORYQUEUES_H_
3 
4 #include "MemoryManager.h"
5 #include "DataMessage.h"
6 
7 namespace cmlabs {
8 
9 static THREAD_RET THREAD_FUNCTION_CALL QueueTest(THREAD_ARG arg);
10 
12  uint32 size;
13  uint32 count;
14  uint32 startPos;
15  uint32 endPos;
16  uint32 padding;
17 };
18 
19 class MessageQueue {
20 public:
21  MessageQueue(char* data, uint32 size);
22  ~MessageQueue();
23 
24  changeSize(uint32 size);
25  changeData(char* data);
26 
27  static bool CreateMessageQueue(uint32& qid, const char* name = NULL);
28  static bool AddMessageToQueue(uint32 qid, DataMessage* msg);
29  static DataMessage* WaitForMessageQueue(uint32 qid, uint32 ms);
30  static uint32 GetMessageQueueSize(uint32 qid);
31  static bool GetMessageQueueByName(uint32& qid, const char* name);
32  static bool DestroyMessageQueue(uint32 qid);
33 
34  static bool AddRequest(DataMessage* msg, uint32& reqID);
35  static bool AddReply(uint32 reqID, bool success, DataMessage* msg);
36  static bool WaitForReply(uint32 reqID, uint32 ms, uint8& status, DataMessage** outMsg);
37  static uint32 GetRequestCount();
38 
39  static bool UnitTest();
40  static bool UnitTestQueues();
41  friend THREAD_RET THREAD_FUNCTION_CALL QueueTest(THREAD_ARG arg);
42 
43 protected:
44  MessageQueueHeader* header;
45 };
46 
47 bool TestMemoryCommander();
48 
49 } // namespace cmlabs
50 
51 #endif //_MEMORYQUEUES_H_
52 
Definition: Bitmap.h:7
Definition: MemoryQueues.h:19
Definition: MemoryQueues.h:11
Definition: DataMessage.h:95