EntropyEngine::Networking::SharedMemoryServer
EntropyEngine::Networking::SharedMemoryServer
Section titled “EntropyEngine::Networking::SharedMemoryServer”Server for accepting shared memory connections. More…
#include <SharedMemoryServer.h>
Inherits from EntropyEngine::Networking::LocalServer, EntropyEngine::Core::EntropyObject
Public Classes
Section titled “Public Classes”| Name | |
|---|---|
| struct | Config Configuration for shared memory server. |
Public Functions
Section titled “Public Functions”| Name | |
|---|---|
| ~SharedMemoryServer() override Destructor cleans up discovery region. | |
| SharedMemoryServer & | operator=(const SharedMemoryServer & ) =delete |
| virtual Result< void > | listen() override Starts listening for connections. |
| virtual bool | isListening() const override Checks if server is currently listening. |
| std::string | getDiscoveryRegionName() const Get the discovery region name. |
| const std::string & | getBaseName() const Get the base name used for regions. |
| virtual Result< void > | close() override Stops listening and closes the server. |
| virtual ConnectionHandle | accept() override Accepts a connection (blocks until client connects). |
| SharedMemoryServer(ConnectionManager * connMgr, std::string baseName) Constructs server with region base name. | |
| SharedMemoryServer(ConnectionManager * connMgr, std::string baseName, const Config & config) Constructs server with configuration. | |
| SharedMemoryServer(const SharedMemoryServer & ) =delete |
Additional inherited members
Section titled “Additional inherited members”Public Functions inherited from EntropyEngine::Networking::LocalServer
| Name | |
|---|---|
| virtual | ~LocalServer() =default |
Protected Functions inherited from EntropyEngine::Networking::LocalServer
| Name | |
|---|---|
| LocalServer() =default |
Protected Classes inherited from EntropyEngine::Core::EntropyObject
| Name | |
|---|---|
| struct | HandleCore Optional handle identity stamped by an owner/registry. |
Public Functions inherited from EntropyEngine::Core::EntropyObject
| Name | |
|---|---|
| virtual | ~EntropyObject() =default |
| virtual const TypeSystem::TypeInfo * | typeInfo() const Optional richer type information; may be null. |
| bool | tryRetain() const Attempts to retain only if the object is still alive. |
| virtual std::string | toString() const Human-readable short string (class@ptr by default). |
| void | retain() const Increments the reference count. |
| void | release() const Decrements the reference count and deletes when it reaches zero. |
| uint32_t | refCount() const Current reference count (approximate under contention). |
| bool | hasHandle() const |
| template <class OwnerT > OwnerT * | handleOwnerAs() const Returns the stamped owner pointer cast to the requested type. |
| const void * | handleOwner() const |
| uint32_t | handleIndex() const |
| uint64_t | handleId() const |
| uint32_t | handleGeneration() const |
| WeakControlBlock * | getWeakControlBlock() const Lazily retrieves or creates the weak control block. |
| virtual std::string | description() const Long-form description; defaults to toString(). |
| virtual std::string | debugString() const Debug-oriented string including refcount and handle when present. |
| virtual const char * | className() const Runtime class name for diagnostics and reflection. |
| virtual uint64_t | classHash() const Stable type hash for cross-language identification. |
| EntropyObject() =default | |
| EntropyObject(EntropyObject && ) =delete | |
| EntropyObject(const EntropyObject & ) =delete |
Protected Functions inherited from EntropyEngine::Core::EntropyObject
| Name | |
|---|---|
| void | _setHandleIdentity(void * owner, uint32_t index, uint32_t generation) |
| void | _clearHandleIdentity() |
Protected Attributes inherited from EntropyEngine::Core::EntropyObject
| Name | |
|---|---|
| std::atomic< WeakControlBlock * > | _weakBlock Lazily allocated control block for weak refs. |
| std::atomic< uint32_t > | _refCount Thread-safe retain/release counter. |
| struct EntropyEngine::Core::EntropyObject::HandleCore | _handle |
Friends inherited from EntropyEngine::Core::EntropyObject
| Name | |
|---|---|
| struct | HandleAccess |
Detailed Description
Section titled “Detailed Description”class EntropyEngine::Networking::SharedMemoryServer;Server for accepting shared memory connections.
SharedMemoryServer creates a discovery region that clients use to initiate connections. When a client connects:
- Server detects client waiting in discovery region
- Server creates a per-connection shared memory region
- Server assigns the region to the client
- Both sides proceed with ring buffer communication
Thread Safety: All public methods are thread-safe. The accept loop runs on a dedicated thread and uses atomic flags for coordination.
ConnectionManager connMgr(64);SharedMemoryServerConfig cfg;cfg.regionSize = 4 * 1024 * 1024; // 4 MiB per connection
auto server = std::make_unique<SharedMemoryServer>(&connMgr, "entropy_canvas", cfg);auto result = server->listen();if (result.failed()) { ... }
// Accept connections (blocking)while (running) { auto conn = server->accept(); if (conn.valid()) { conn.send(data); }}
server->close();Public Functions Documentation
Section titled “Public Functions Documentation”function ~SharedMemoryServer
Section titled “function ~SharedMemoryServer”~SharedMemoryServer() overrideDestructor cleans up discovery region.
function operator=
Section titled “function operator=”SharedMemoryServer & operator=( const SharedMemoryServer &) =deletefunction listen
Section titled “function listen”virtual Result< void > listen() overrideStarts listening for connections.
Return: Result indicating success or failure
Reimplements: EntropyEngine::Networking::LocalServer::listen
function isListening
Section titled “function isListening”inline virtual bool isListening() const overrideChecks if server is currently listening.
Return: true if listening for connections
Reimplements: EntropyEngine::Networking::LocalServer::isListening
function getDiscoveryRegionName
Section titled “function getDiscoveryRegionName”inline std::string getDiscoveryRegionName() constGet the discovery region name.
Return: Discovery region name ({baseName}_discovery)
function getBaseName
Section titled “function getBaseName”inline const std::string & getBaseName() constGet the base name used for regions.
Return: Region base name
function close
Section titled “function close”virtual Result< void > close() overrideStops listening and closes the server.
Return: Result indicating success or failure
Reimplements: EntropyEngine::Networking::LocalServer::close
function accept
Section titled “function accept”virtual ConnectionHandle accept() overrideAccepts a connection (blocks until client connects).
Return: ConnectionHandle for the accepted connection, or invalid handle on error
Reimplements: EntropyEngine::Networking::LocalServer::accept
function SharedMemoryServer
Section titled “function SharedMemoryServer”SharedMemoryServer( ConnectionManager * connMgr, std::string baseName)Constructs server with region base name.
Parameters:
- connMgr Connection manager that will own accepted connections
- baseName Base name for shared memory regions
function SharedMemoryServer
Section titled “function SharedMemoryServer”SharedMemoryServer( ConnectionManager * connMgr, std::string baseName, const Config & config)Constructs server with configuration.
Parameters:
- connMgr Connection manager that will own accepted connections
- baseName Base name for shared memory regions
- config Server configuration
function SharedMemoryServer
Section titled “function SharedMemoryServer”SharedMemoryServer( const SharedMemoryServer &) =deleteUpdated on 2026-01-26 at 16:50:32 -0500