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

Template implementations of the GenericMemoryMap shared-map algorithms. More...

#include "Utils.h"
Include dependency graph for MemoryMaps.tpl.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  cmlabs

Detailed Description

Template implementations of the GenericMemoryMap shared-map algorithms.

Included at the bottom of MemoryMaps.h and DataMapsMemory.h so the template bodies are visible wherever the maps are instantiated. The algorithms operate directly on raw mapped map regions: a GenericMapHeader, an occupancy bitfield, then fixed-size entries. Callers are responsible for holding the owning segment's cross-process mutex.

Warning
These functions write directly into shared memory; keep them in sync with the entry-struct layouts and rebuild all binaries after any change (make clean && make).

Typical two-phase usage (caller holds the segment mutex; data is the raw mapped map region starting with a GenericMapHeader):

uint16 id;
TypeMapEntry* e = GenericMemoryMap<TypeMapEntry,uint16>::CreateFirstFreeEntry(data, id, "Vision.Face");
if (e) {
// ... negotiate id with the rest of the cluster ...
GenericMemoryMap<TypeMapEntry,uint16>::ConfirmEntry(data, id); // commit (status 2)
// or GenericMemoryMap<TypeMapEntry,uint16>::CancelEntry(data, id); // roll back
}
uint16 found = GenericMemoryMap<TypeMapEntry,uint16>::GetEntryID(data, "Vision.Face");

Definition in file MemoryMaps.tpl.h.