10 if (!data || !size)
return false;
19 if (!data || !size)
return false;
24 if (!data || !msg)
return false;
26 uint32 msgSize = msg->
getSize();
28 uint32 spaceToEnd, inUse = 0, inUse2 = 0;
33 spaceToEnd = qDataSize;
34 if (spaceToEnd >= msgSize) {
36 memcpy(qData, msg->
data, msgSize);
48 spaceToEnd = qDataSize - qHeader->
endPos;
49 if (spaceToEnd >= msgSize) {
51 memcpy(qData+qHeader->
endPos, msg->
data, msgSize);
52 qHeader->
endPos += msgSize;
56 else if (qHeader->
startPos >= msgSize) {
58 memset(qData+qHeader->
endPos, 0, spaceToEnd);
61 memcpy(qData, msg->
data, msgSize);
72 if (spaceToEnd > msgSize) {
74 memcpy(qData+qHeader->
endPos, msg->
data, msgSize);
75 qHeader->
endPos += msgSize;
87 if (!data)
return NULL;
109 if (!data || !count)
return false;
117 header->
size = requestsSize;
129 if (!data || !count)
return false;
134 if (!data)
return false;
146 uint64 reqID = (uint64)loc;
199 if (offset > header->
size)
Static algorithms for request queues and the request-status map used by the shared-memory request/rep...
The central Psyclone data container: a self-contained binary message with typed, named user entries.
DataMessageHeader * data
Pointer to the message's flat memory block (header + user entries).
uint32 getSize()
getSize() Get message size Many types of data of any size can be put into a message as user entries; ...
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.
uint64 GetTimeNow()
Return the current absolute time (µs since year 0) according to the TMC.
bool GetFirstFreeBitLoc(const char *bitfield, uint32 bytesize, uint32 &loc)
Find the first 0 (free) bit.
bool SetBit(uint32 loc, bit value, char *bitfield, uint32 bytesize)
Set bit loc to value.
uint32 Calc32BitFieldSize(uint32 bitsize)
Compute the byte size needed for a bitfield of bitsize bits, rounded up to a 32-bit boundary.
One request transaction's status record.