CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
TemporalMemory.h File Reference

Slot/bin shared-memory store for time-limited DataMessages (the node's "dynamic" memory). More...

#include "MemoryManager.h"
#include "PsyTime.h"
Include dependency graph for TemporalMemory.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  cmlabs::SlotEntryStruct
 Per-message slot record: which bin/blocks hold the message and until when. More...
struct  cmlabs::TemporalMemoryStruct
 Root header of the temporal-memory segment. More...
struct  cmlabs::BinHeaderStruct
 Header of one fixed-block-size bin inside the temporal segment. More...
class  cmlabs::TemporalMemory
 Accessor for the temporal (dynamic) message store in shared memory. More...

Namespaces

namespace  cmlabs

Macros

#define CHECKTEMPORALMEMORYSERIAL   if (serial != master->getDynamicShmemSerial()) {if (!open()) {mutex->leave();return 0;}}
 Re-open the temporal segment if the master's resize serial no longer matches ours (i.e.
Message-id packing macros

A 64-bit message id encodes node (16 bits), slot serial (16 bits) and slot index (32 bits).

#define GETMSGNODE(id)
#define GETMSGSERIAL(id)
#define GETMSGSLOT(id)
#define SETMSGID(id, node, serial, slot)

Detailed Description

Slot/bin shared-memory store for time-limited DataMessages (the node's "dynamic" memory).

Every message published in a Psyclone system carries an end-of-life (EOL) timestamp. TemporalMemory stores such messages in a single shared segment organised as: a TemporalMemoryStruct header, a slot bitfield, an array of SlotEntryStruct (one per stored message), and a series of bins — pools of fixed-size blocks (small bins for small messages, larger bins for big ones). A message occupies contiguous blocks in exactly one bin; the slot records where. Expired slots are reclaimed by maintenance().

Message ids pack node|serial|slot (see GETMSGNODE/GETMSGSERIAL/GETMSGSLOT); the serial guards against reading a slot that has been recycled since the id was issued.

Warning
Shared-memory layouts; changing any struct here requires a full rebuild of all binaries (make clean && make) — see MemoryManager.h for the ABI warning.

Definition in file TemporalMemory.h.

Macro Definition Documentation

◆ CHECKTEMPORALMEMORYSERIAL

#define CHECKTEMPORALMEMORYSERIAL   if (serial != master->getDynamicShmemSerial()) {if (!open()) {mutex->leave();return 0;}}

Re-open the temporal segment if the master's resize serial no longer matches ours (i.e.

another process re-created the segment); bails out of the calling method on failure.

Definition at line 95 of file TemporalMemory.h.

Referenced by cmlabs::TemporalMemory::getCopyOfMessage(), cmlabs::TemporalMemory::getMemoryUsage(), cmlabs::TemporalMemory::insertMessage(), and cmlabs::TemporalMemory::maintenance().

◆ GETMSGNODE

#define GETMSGNODE ( id)
Value:
(uint16)((id & 0xffff000000000000L)>>48)

Definition at line 87 of file TemporalMemory.h.

Referenced by cmlabs::TemporalMemory::getCopyOfMessage().

◆ GETMSGSERIAL

#define GETMSGSERIAL ( id)
Value:
(uint16)((id & 0x0000ffff00000000L)>>32)

Definition at line 88 of file TemporalMemory.h.

◆ GETMSGSLOT

#define GETMSGSLOT ( id)
Value:
(uint32)(id & 0x00000000ffffffffL)

Definition at line 89 of file TemporalMemory.h.

◆ SETMSGID

#define SETMSGID ( id,
node,
serial,
slot )
Value:
id = (((uint64)node) << 48) | (((uint64)serial) << 32) | ((uint64)slot)

Definition at line 90 of file TemporalMemory.h.

Referenced by cmlabs::TemporalMemory::insertMessage().