Entropic 2.14.3
Local-first agentic inference engine
Loading...
Searching...
No Matches
entropic::SessionScoped< T > Class Template Reference

One T per session key, under one leaf mutex (gh#158). More...

#include <entropic/mcp/session_scoped.h>

Public Member Functions

template<typename Fn >
auto with (const std::string &key, Fn &&fn)
 Run fn on key's state, creating it empty on first use.
 
template<typename Fn >
auto peek (const std::string &key, Fn &&fn) const
 Run fn on key's state WITHOUT creating it.
 
bool release (const std::string &key)
 Forget key's state.
 
std::size_t session_count () const
 Sessions currently holding state (bounded-growth probe).
 

Detailed Description

template<typename T>
class entropic::SessionScoped< T >

One T per session key, under one leaf mutex (gh#158).

Every accessor takes the lock for its whole body and calls nothing but the supplied functor under it, so it is a LEAF lock: nothing that holds it waits on another. A functor must not re-enter the same instance.

Template Parameters
TPer-session state (default-constructible).
Version
2.13.0

Definition at line 61 of file session_scoped.h.

Member Function Documentation

◆ peek()

template<typename T >
template<typename Fn >
auto entropic::SessionScoped< T >::peek ( const std::string &  key,
Fn &&  fn 
) const
inline

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
keySession key.
fnCallable taking const T* (nullptr when absent).
Returns
Whatever fn returns. @req REQ-LOOP-009
Version
2.13.0

Definition at line 90 of file session_scoped.h.

◆ release()

template<typename T >
bool entropic::SessionScoped< T >::release ( const std::string &  key)
inline

Forget key's state.

Parameters
keySession key.
Returns
true when an entry existed and was erased. @req REQ-LOOP-009
Version
2.13.0

Definition at line 103 of file session_scoped.h.

◆ session_count()

template<typename T >
std::size_t entropic::SessionScoped< T >::session_count ( ) const
inline

Sessions currently holding state (bounded-growth probe).

Returns
Entry count. @req REQ-LOOP-009
Version
2.13.0

Definition at line 114 of file session_scoped.h.

◆ with()

template<typename T >
template<typename Fn >
auto entropic::SessionScoped< T >::with ( const std::string &  key,
Fn &&  fn 
)
inline

Run fn on key's state, creating it empty on first use.

Parameters
keySession key.
fnCallable taking T&.
Returns
Whatever fn returns. @req REQ-LOOP-009
Version
2.13.0

Definition at line 72 of file session_scoped.h.


The documentation for this class was generated from the following file: