EntropyEngine::Networking::SharedMemory::PlatformOps
EntropyEngine::Networking::SharedMemory::PlatformOps
Section titled “EntropyEngine::Networking::SharedMemory::PlatformOps”Platform-specific shared memory operations. More…
#include <SharedMemoryPlatform.h>
Public Functions
Section titled “Public Functions”| Name | |
|---|---|
| void | wakeAll(std::atomic< uint32_t > * addr) Wake all threads waiting on an atomic flag. |
| void | wake(std::atomic< uint32_t > * addr) Wake threads waiting on an atomic flag. |
| bool | waitUntilChanged(std::atomic< uint32_t > * addr, uint32_t expected, int timeoutMs) Wait until an atomic flag changes from expected value. |
| void | unmapRegion(void * ptr, size_t size) Unmap a previously mapped region. |
| NativeHandle | openRegion(const char * name) Open an existing shared memory region. |
| void * | mapRegion(NativeHandle handle, size_t size) Map a shared memory region into process address space. |
| bool | isAvailable() Check if shared memory is available on this platform. |
| std::string | getLastErrorString() Get the last platform error as a string. |
| void | destroyRegion(const char * name) Destroy a shared memory region. |
| NativeHandle | createRegion(const char * name, size_t size) Create a new shared memory region. |
| void | closeRegion(NativeHandle handle) Close a region handle. |
Detailed Description
Section titled “Detailed Description”struct EntropyEngine::Networking::SharedMemory::PlatformOps;Platform-specific shared memory operations.
All methods are static and thread-safe. Each platform provides its own implementation in SharedMemoryPlatformUnix.cpp or SharedMemoryPlatformWin32.cpp.
Public Functions Documentation
Section titled “Public Functions Documentation”function wakeAll
Section titled “function wakeAll”static void wakeAll( std::atomic< uint32_t > * addr)Wake all threads waiting on an atomic flag.
Parameters:
- addr Address of the atomic flag
function wake
Section titled “function wake”static void wake( std::atomic< uint32_t > * addr)Wake threads waiting on an atomic flag.
Parameters:
- addr Address of the atomic flag
Uses platform-specific futex (Linux), ulock (macOS), or WaitOnAddress (Windows).
function waitUntilChanged
Section titled “function waitUntilChanged”static bool waitUntilChanged( std::atomic< uint32_t > * addr, uint32_t expected, int timeoutMs)Wait until an atomic flag changes from expected value.
Parameters:
- addr Address of the atomic flag
- expected Value to wait for change from
- timeoutMs Maximum wait time in milliseconds (-1 for infinite)
Return: true if value changed, false if timed out
Blocks until the value at addr is no longer equal to expected, or timeout expires.
function unmapRegion
Section titled “function unmapRegion”static void unmapRegion( void * ptr, size_t size)Unmap a previously mapped region.
Parameters:
- ptr Pointer returned by mapRegion
- size Size of the mapped region
function openRegion
Section titled “function openRegion”static NativeHandle openRegion( const char * name)Open an existing shared memory region.
Parameters:
- name Region name (must match createRegion name)
Return: Handle to the opened region, or INVALID_HANDLE_VALUE_SHM on failure
Opens a shared memory region previously created by another process.
function mapRegion
Section titled “function mapRegion”static void * mapRegion( NativeHandle handle, size_t size)Map a shared memory region into process address space.
Parameters:
- handle Handle from createRegion or openRegion
- size Size of the region to map
Return: Pointer to mapped memory, or nullptr on failure
function isAvailable
Section titled “function isAvailable”static bool isAvailable()Check if shared memory is available on this platform.
Return: true if shared memory operations are supported
function getLastErrorString
Section titled “function getLastErrorString”static std::string getLastErrorString()Get the last platform error as a string.
Return: Error description
Returns a human-readable string for the last platform-specific error.
function destroyRegion
Section titled “function destroyRegion”static void destroyRegion( const char * name)Destroy a shared memory region.
Parameters:
- name Region name
Removes the region from the filesystem/namespace. Existing mappings remain valid until unmapped.
function createRegion
Section titled “function createRegion”static NativeHandle createRegion( const char * name, size_t size)Create a new shared memory region.
Parameters:
- name Region name (platform-specific prefixing is handled internally)
- size Size of the region in bytes
Return: Handle to the created region, or INVALID_HANDLE_VALUE_SHM on failure
Creates a new shared memory region with the given name. The region is created with read/write permissions for the owner.
function closeRegion
Section titled “function closeRegion”static void closeRegion( NativeHandle handle)Close a region handle.
Parameters:
- handle Handle to close
Does not destroy the region if other processes have it open.
Updated on 2026-01-26 at 17:14:35 -0500