include/entropic/mcp/session_scoped.h¶
include/entropic/mcp/session_scoped.h
entropic::SessionScoped
One T per session key, under one leaf mutex (gh#158).
entropic::SessionScoped< T >
auto entropic::SessionScoped< T >::with(const std::string &key, Fn &&fn)
Run fn on key 's state, creating it empty on first use.
- Parameters
key— Session key.fn— Callable taking T&.
- Returns
- Whatever fn returns.
auto entropic::SessionScoped< T >::peek(const std::string &key, Fn &&fn) const
Run fn on key 's state WITHOUT creating it.
A lookup must not allocate an entry, or merely asking "did this session read X?" would grow the map for sessions that never read.
- Parameters
key— Session key.fn— Callable taking const T* (nullptr when absent).
- Returns
- Whatever fn returns.
bool entropic::SessionScoped< T >::release(const std::string &key)
Forget key 's state.
- Parameters
key— Session key.
- Returns
- true when an entry existed and was erased.
std::size_t entropic::SessionScoped< T >::session_count() const
Sessions currently holding state (bounded-growth probe).
- Returns
- Entry count.
entropic::SessionStateOwner
A server that keeps state per session and can release it (gh#158).
Derived by entropic::EntropicServer, entropic::FilesystemServer.
virtual entropic::SessionStateOwner::~SessionStateOwner()=default
Virtual destructor for a polymorphic mixin.
virtual bool entropic::SessionStateOwner::release_session(const std::string &key)=0
Drop everything this server holds for key .
- Parameters
key— Session key ("" = the default session).
- Returns
- true when anything was released.
virtual std::size_t entropic::SessionStateOwner::session_count() const =0
Sessions this server currently holds state for.
- Returns
- Session count (the largest of its per-session maps).