18#if !defined(_TEMPORALMEMORY_H_)
19#define _TEMPORALMEMORY_H_
87#define GETMSGNODE(id) (uint16)((id & 0xffff000000000000L)>>48)
88#define GETMSGSERIAL(id) (uint16)((id & 0x0000ffff00000000L)>>32)
89#define GETMSGSLOT(id) (uint32)(id & 0x00000000ffffffffL)
90#define SETMSGID(id,node,serial,slot) id = (((uint64)node) << 48) | (((uint64)serial) << 32) | ((uint64)slot)
95#define CHECKTEMPORALMEMORYSERIAL if (serial != master->getDynamicShmemSerial()) {if (!open()) {mutex->leave();return 0;}}
128 bool create(uint32 slotCount, uint16 binCount, uint32 minBlockSize, uint32 maxBlockSize, uint64 initSize, uint64 maxSize, uint32 growSteps = 8);
156 std::vector<BinHeaderStruct> calcBinHeaders(uint32 binCount, uint32 minBlockSize, uint32 maxBlockSize, uint64 binDataSize);
157 BinHeaderStruct* getBestBin(uint32 size, uint32& bin, uint32 &blocksNeeded);
158 char* getMemoryBlock(uint64
id);
159 bool checkSlots(uint64 now);
162 bool resizeBin(uint32 bin,
BinHeaderStruct* binHeader, uint32 msgSize);
163 std::vector<BinHeaderStruct> calcBinHeadersGrowth(uint32 bin = 0, uint32 msgSize = 0);
164 bool resizeMemory(uint32 slotGrowth, std::vector<BinHeaderStruct>& binHeaderSizes);
Central shared-memory manager for a Psyclone node: master segment, per-subsystem shared maps and the ...
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.
Pure-virtual interface for shared-segment bookkeeping (implemented by MasterMemory).
bool getMemoryUsage(uint64 &alloc, uint64 &usage)
Report allocation/usage of the temporal segment.
bool maintenance()
Expire slots whose EOL has passed and reclaim their blocks.
bool logUsage()
Write current usage statistics to the log.
DataMessage * getCopyOfMessage(uint64 id)
Retrieve a private copy of a stored message.
bool setNodeID(uint16 id)
Set the node id used when composing message ids.
bool insertMessage(DataMessage *msg, uint64 &id)
Copy msg into shared memory until its EOL passes.
bool create(uint32 slotCount, uint16 binCount, uint32 minBlockSize, uint32 maxBlockSize, uint64 initSize, uint64 maxSize, uint32 growSteps=8)
Create the temporal segment (master process only).
TemporalMemory(MemoryController *master)
static bool UnitTest()
Self-test of the temporal store.
bool open()
Attach to the existing temporal segment (size/serial from the master).
Recursive mutual-exclusion lock, optionally named for cross-process use.
Per-message slot record: which bin/blocks hold the message and until when.
uint64 size
Message byte size; 0 means the slot is not in use.
uint64 eol
Absolute end-of-life timestamp (µs); slot reclaimable after this.
uint32 bin
Index of the bin holding the message data.
uint32 startBlock
First block index used within the bin.
uint16 serial
Reuse serial; incremented when the slot is recycled and checked against the serial packed in the mess...
uint64 usage
Bytes actually reserved (blocks used * blocksize >= size).
uint32 blockUsage
Number of contiguous blocks used.
uint64 offset
Byte offset of the message inside the bin's data area.
Root header of the temporal-memory segment.
uint64 growStep
Byte increment used when growing the segment.
uint64 size
Total segment size in bytes.
uint32 slotsInUse
Slots currently holding live messages.
uint64 maxSize
Hard ceiling for segment growth in bytes.
uint32 cid
Check/magic id validated on attach.
uint64 lastCheckTime
Timestamp of the last expiry sweep.
uint16 binCount
Number of block-size bins.
uint64 checkTimeInterval
Interval between expiry sweeps (µs).
uint32 slotCount
Total message slots allocated.
uint64 usage
Bytes currently in use across all bins.