CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
cmlabs::PsycloneIndex Class Reference

Accessor for the machine-global instance index segment. More...

#include <MemoryManager.h>

Public Member Functions

 PsycloneIndex ()
 ~PsycloneIndex ()
bool init (uint16 port, uint64 instID)
 Attach to (or create) the index segment and claim/refresh the slot for this instance.
bool setStatus (uint8 status)
 Update this instance's status and heartbeat in the shared index.

Static Public Member Functions

static bool GetStatus (uint16 port, uint8 &status, uint64 &heartbeat)
 Look up the status of the instance registered on port.

Detailed Description

Accessor for the machine-global instance index segment.

Each running node creates one PsycloneIndex, registers its port/instance id via init(), and keeps its status/heartbeat fresh via setStatus(). Other processes query liveness with the static GetStatus() without needing an object of their own. Thread-safety: updates are simple word writes into shared memory; concurrent readers may observe a slightly stale status, which is acceptable for liveness polling.

Definition at line 151 of file MemoryManager.h.

Constructor & Destructor Documentation

◆ PsycloneIndex()

cmlabs::PsycloneIndex::PsycloneIndex ( )

Definition at line 39 of file MemoryManager.cpp.

◆ ~PsycloneIndex()

cmlabs::PsycloneIndex::~PsycloneIndex ( )

Member Function Documentation

◆ GetStatus()

bool cmlabs::PsycloneIndex::GetStatus ( uint16 port,
uint8 & status,
uint64 & heartbeat )
static

Look up the status of the instance registered on port.

Parameters
portNode port to query.
statusReceives the PSYCLONE_STATUS_* value.
heartbeatReceives the last heartbeat timestamp (µs).
Returns
true if an entry for port exists in the index.

Definition at line 19 of file MemoryManager.cpp.

References cmlabs::PsycloneIndexEntry::heartbeat, cmlabs::utils::OpenSharedMemorySegment(), cmlabs::PsycloneIndexEntry::port, PSYCLONE_INDEX_MAXCOUNT, PSYCLONE_INDEX_SIZE, PSYCLONE_STATUS_NONE, and cmlabs::PsycloneIndexEntry::status.

Referenced by cmlabs::MemoryManager::connect(), cmlabs::MemoryManager::create(), and cmlabs::MemoryManager::getNodeStatus().

◆ init()

bool cmlabs::PsycloneIndex::init ( uint16 port,
uint64 instID )

Attach to (or create) the index segment and claim/refresh the slot for this instance.

Parameters
portPort this node listens on.
instIDUnique instance id.
Returns
true on success.

Definition at line 52 of file MemoryManager.cpp.

References cmlabs::utils::CreateSharedMemorySegment(), cmlabs::utils::OpenSharedMemorySegment(), cmlabs::PsycloneIndexEntry::port, PSYCLONE_INDEX_MAXCOUNT, PSYCLONE_INDEX_SIZE, and PSYCLONEINDEXID.

◆ setStatus()

bool cmlabs::PsycloneIndex::setStatus ( uint8 status)

Update this instance's status and heartbeat in the shared index.

Parameters
statusNew PSYCLONE_STATUS_* value.
Returns
true if the entry was written.

Definition at line 84 of file MemoryManager.cpp.

References cmlabs::GetTimeNow(), and cmlabs::PsycloneIndexEntry::status.

Referenced by ~PsycloneIndex().


The documentation for this class was generated from the following files: