Skip to content

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

Name
structConfig
Configuration for shared memory server.
Name
~SharedMemoryServer() override
Destructor cleans up discovery region.
SharedMemoryServer &operator=(const SharedMemoryServer & ) =delete
virtual Result< void >listen() override
Starts listening for connections.
virtual boolisListening() const override
Checks if server is currently listening.
std::stringgetDiscoveryRegionName() 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 ConnectionHandleaccept() 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

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
structHandleCore
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.
booltryRetain() const
Attempts to retain only if the object is still alive.
virtual std::stringtoString() const
Human-readable short string (class@ptr by default).
voidretain() const
Increments the reference count.
voidrelease() const
Decrements the reference count and deletes when it reaches zero.
uint32_trefCount() const
Current reference count (approximate under contention).
boolhasHandle() const
template <class OwnerT >
OwnerT *
handleOwnerAs() const
Returns the stamped owner pointer cast to the requested type.
const void *handleOwner() const
uint32_thandleIndex() const
uint64_thandleId() const
uint32_thandleGeneration() const
WeakControlBlock *getWeakControlBlock() const
Lazily retrieves or creates the weak control block.
virtual std::stringdescription() const
Long-form description; defaults to toString().
virtual std::stringdebugString() const
Debug-oriented string including refcount and handle when present.
virtual const char *className() const
Runtime class name for diagnostics and reflection.
virtual uint64_tclassHash() 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
structHandleAccess
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:

  1. Server detects client waiting in discovery region
  2. Server creates a per-connection shared memory region
  3. Server assigns the region to the client
  4. 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();
~SharedMemoryServer() override

Destructor cleans up discovery region.

SharedMemoryServer & operator=(
const SharedMemoryServer &
) =delete
virtual Result< void > listen() override

Starts listening for connections.

Return: Result indicating success or failure

Reimplements: EntropyEngine::Networking::LocalServer::listen

inline virtual bool isListening() const override

Checks if server is currently listening.

Return: true if listening for connections

Reimplements: EntropyEngine::Networking::LocalServer::isListening

inline std::string getDiscoveryRegionName() const

Get the discovery region name.

Return: Discovery region name ({baseName}_discovery)

inline const std::string & getBaseName() const

Get the base name used for regions.

Return: Region base name

virtual Result< void > close() override

Stops listening and closes the server.

Return: Result indicating success or failure

Reimplements: EntropyEngine::Networking::LocalServer::close

virtual ConnectionHandle accept() override

Accepts a connection (blocks until client connects).

Return: ConnectionHandle for the accepted connection, or invalid handle on error

Reimplements: EntropyEngine::Networking::LocalServer::accept

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
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
SharedMemoryServer(
const SharedMemoryServer &
) =delete

Updated on 2026-01-26 at 16:50:32 -0500