|
CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
|
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. | |
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.
| cmlabs::PsycloneIndex::PsycloneIndex | ( | ) |
Definition at line 39 of file MemoryManager.cpp.
| cmlabs::PsycloneIndex::~PsycloneIndex | ( | ) |
Definition at line 44 of file MemoryManager.cpp.
References cmlabs::utils::CloseSharedMemorySegment(), PSYCLONE_INDEX_SIZE, PSYCLONE_STATUS_ENDED, and setStatus().
|
static |
Look up the status of the instance registered on port.
| port | Node port to query. |
| status | Receives the PSYCLONE_STATUS_* value. |
| heartbeat | Receives the last heartbeat timestamp (µs). |
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().
| bool cmlabs::PsycloneIndex::init | ( | uint16 | port, |
| uint64 | instID ) |
Attach to (or create) the index segment and claim/refresh the slot for this instance.
| port | Port this node listens on. |
| instID | Unique instance id. |
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.
| bool cmlabs::PsycloneIndex::setStatus | ( | uint8 | status | ) |
Update this instance's status and heartbeat in the shared index.
| status | New PSYCLONE_STATUS_* value. |
Definition at line 84 of file MemoryManager.cpp.
References cmlabs::GetTimeNow(), and cmlabs::PsycloneIndexEntry::status.
Referenced by ~PsycloneIndex().