CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
MemoryQueues.h
Go to the documentation of this file.
1
14
15#if !defined(_MEMORYQUEUES_H_)
16#define _MEMORYQUEUES_H_
17
18#include "MemoryManager.h"
19#include "DataMessage.h"
20
21namespace cmlabs {
22
24
29 uint32 size;
30 uint32 count;
31 uint32 startPos;
32 uint32 endPos;
33 uint32 padding;
34};
35
49public:
51 MessageQueue(char* data, uint32 size);
53
54 changeSize(uint32 size);
55 changeData(char* data);
56
58 static bool CreateMessageQueue(uint32& qid, const char* name = NULL);
60 static bool AddMessageToQueue(uint32 qid, DataMessage* msg);
62 static DataMessage* WaitForMessageQueue(uint32 qid, uint32 ms);
64 static uint32 GetMessageQueueSize(uint32 qid);
66 static bool GetMessageQueueByName(uint32& qid, const char* name);
68 static bool DestroyMessageQueue(uint32 qid);
69
71 static bool AddRequest(DataMessage* msg, uint32& reqID);
73 static bool AddReply(uint32 reqID, bool success, DataMessage* msg);
76 static bool WaitForReply(uint32 reqID, uint32 ms, uint8& status, DataMessage** outMsg);
78 static uint32 GetRequestCount();
79
80 static bool UnitTest();
81 static bool UnitTestQueues();
83
84protected:
86};
87
89
90} // namespace cmlabs
91
92#endif //_MEMORYQUEUES_H_
93
The binary DataMessage container — the central data-exchange object of Psyclone/CMSDK.
Central shared-memory manager for a Psyclone node: master segment, per-subsystem shared maps and the ...
#define THREAD_RET
Definition Utils.h:127
#define THREAD_FUNCTION_CALL
Definition Utils.h:129
#define THREAD_ARG
Definition Utils.h:130
The central Psyclone data container: a self-contained binary message with typed, named user entries.
static uint32 GetRequestCount()
static bool GetMessageQueueByName(uint32 &qid, const char *name)
Look up a queue id by its global name.
static bool WaitForReply(uint32 reqID, uint32 ms, uint8 &status, DataMessage **outMsg)
Block up to ms for the reply to reqID.
static uint32 GetMessageQueueSize(uint32 qid)
static bool UnitTestQueues()
Self-test of the raw queue ring buffer.
static bool DestroyMessageQueue(uint32 qid)
Destroy a queue and release its shared memory.
MessageQueueHeader * header
Mapped queue header (points into shared memory; not owned).
friend THREAD_RET THREAD_FUNCTION_CALL QueueTest(THREAD_ARG arg)
changeSize(uint32 size)
Update the wrapper's notion of the region size.
static bool AddMessageToQueue(uint32 qid, DataMessage *msg)
Append a message (copied into shared memory).
static DataMessage * WaitForMessageQueue(uint32 qid, uint32 ms)
Block up to ms milliseconds for a message.
changeData(char *data)
Re-point the wrapper at a new mapped address.
static bool UnitTest()
Self-test of queue + request logic.
MessageQueue(char *data, uint32 size)
Attach this wrapper to a raw queue region.
static bool AddReply(uint32 reqID, bool success, DataMessage *msg)
Post the reply for request reqID.
static bool CreateMessageQueue(uint32 &qid, const char *name=NULL)
Create a new shared queue.
static bool AddRequest(DataMessage *msg, uint32 &reqID)
Submit a request message.
bool TestMemoryCommander()
Self-test hook for the memory commander.
static THREAD_RET THREAD_FUNCTION_CALL QueueTest(THREAD_ARG arg)
On-segment header of a circular message queue (legacy 32-bit layout).
uint32 padding
Alignment/reserved.
uint32 size
Total size of the queue region in bytes (header + buffer).
uint32 count
Number of messages currently in the queue.
uint32 startPos
Read offset into the circular buffer.
uint32 endPos
Write offset into the circular buffer.