CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
MemoryRequestQueues.h
Go to the documentation of this file.
1
13
14#if !defined(_MEMORYREQUESTQUEUES_H_)
15#define _MEMORYREQUESTQUEUES_H_
16
17#include "PsyTime.h"
18#include "DataMessage.h"
19
20namespace cmlabs {
21
24#define MEMORYREQUEST_ERROR 0
25#define MEMORYREQUEST_IDLE 1
26#define MEMORYREQUEST_INIT 2
27#define MEMORYREQUEST_SUBMITTED 3
28#define MEMORYREQUEST_RECEIVED 4
29#define MEMORYREQUEST_STARTED 5
30#define MEMORYREQUEST_COMPLETED 6
31#define MEMORYREQUEST_REPLIED 7
32#define MEMORYREQUEST_REPLYRECEIVED 8
33#define MEMORYREQUEST_FINISHED 9
35
39 uint32 size;
40 uint32 count;
43 uint16 status;
44 uint32 startPos;
45 uint32 endPos;
46 uint32 padding;
47 // N x DataMessages from startPos to endPos
48};
49
50
51
55 uint32 size;
56 uint32 countTotal;
57 uint32 countInUse;
60 uint16 status;
62 // Bitfield
63 // countTotal x Entries
64};
65
69 uint64 id;
72 uint16 status;
73 uint32 from; // id of connection making the request
74 uint32 to; // id of connection processing the request
75};
76
83public:
84 static bool InitQueue(char* data, uint32 size);
85 static bool CheckQueue(char* data, uint32 size);
86 static bool AddToQueue(char* data, DataMessage* msg);
87 static DataMessage* GetNextQueueMessage(char* data);
88
89 static bool InitRequestMap(char* data, uint32 count);
90 static bool CheckRequestMap(char* data, uint32 count);
91 static uint64 AddNewRequest(char* data, uint16 status, uint32 from, uint32 to);
92 static bool SetRequestStatus(char* data, uint64 id, uint16 status);
93 static uint32 GetRequestStatus(char* data, uint64 id, uint64& createdTime, uint64& lastUpdateTime);
94 static bool CloseRequest(char* data, uint64 id);
95private:
96 static RequestStatusEntry* GetRequestEntry(char* data, uint64 id);
97};
98
99} // namespace cmlabs
100
101#endif //_MEMORYREQUESTQUEUES_H_
102
The binary DataMessage container — the central data-exchange object of Psyclone/CMSDK.
CMSDK time: µs-resolution 64-bit timestamps and the Time Mapping Constant (TMC).
The central Psyclone data container: a self-contained binary message with typed, named user entries.
Static helpers for request queues and the request-status map (raw shared memory).
static bool InitRequestMap(char *data, uint32 count)
Initialise a status map for count requests.
static uint64 AddNewRequest(char *data, uint16 status, uint32 from, uint32 to)
Allocate a request slot.
static DataMessage * GetNextQueueMessage(char *data)
Pop the next message.
static bool AddToQueue(char *data, DataMessage *msg)
Append a copy of msg (caller keeps ownership).
static bool CloseRequest(char *data, uint64 id)
Release the request slot.
static bool SetRequestStatus(char *data, uint64 id, uint16 status)
Advance a request's MEMORYREQUEST_* status.
static uint32 GetRequestStatus(char *data, uint64 id, uint64 &createdTime, uint64 &lastUpdateTime)
static bool CheckQueue(char *data, uint32 size)
Validate an existing queue region.
static bool CheckRequestMap(char *data, uint32 count)
Validate an existing status map.
static bool InitQueue(char *data, uint32 size)
Initialise a queue region of size bytes.
Header of one circular request queue; followed by serialized DataMessages between startPos and endPos...
One request transaction's status record.
uint64 createdTime
uint32 to
uint32 from
uint64 lastUpdateTime
uint16 status
uint64 id
Header of the request-status table; followed by a bitfield and countTotal RequestStatusEntry records.