Entropic 2.14.3
Local-first agentic inference engine
Loading...
Searching...
No Matches
entropic::ToolRootLock Class Reference

Shared/exclusive lock whose exclusive side is re-entrant for its owner, and whose owner passes through the shared side. More...

#include <entropic/mcp/tool_root_lock.h>

Public Member Functions

void lock ()
 Acquire exclusively; re-entrant for the owning thread.
 
void unlock ()
 Release one exclusive level; the last one frees the lock.
 
bool lock_shared (const std::string &what)
 Acquire shared, unless this thread owns the exclusive side.
 
void unlock_shared ()
 Release a shared hold taken by lock_shared() == true.
 
bool owned_by_this_thread () const
 Whether the calling thread holds the exclusive side.
 

Detailed Description

Shared/exclusive lock whose exclusive side is re-entrant for its owner, and whose owner passes through the shared side.

Satisfies BasicLockable (lock / unlock), so std::lock_guard works for the exclusive side; ToolRootShared is the RAII shared side.

Returns
n/a (class). @req REQ-LOOP-009 @req REQ-DELEG-005
Version
2.13.0

Definition at line 64 of file tool_root_lock.h.

Member Function Documentation

◆ lock()

void entropic::ToolRootLock::lock ( )

Acquire exclusively; re-entrant for the owning thread.

Version
2.13.0

Only the owner ever stores its own id into owner_, so a non-owner can never read its own id there and always takes the mutex — which is what makes the unlocked owner_ check sound.

@req REQ-LOOP-009 @req REQ-DELEG-005

Version
2.13.0

Definition at line 26 of file tool_root_lock.cpp.

◆ lock_shared()

bool entropic::ToolRootLock::lock_shared ( const std::string &  what)

Acquire shared, unless this thread owns the exclusive side.

A dispatch that has to wait says so in the log, naming what waited: a tool call stalled behind another session's sandboxed delegation is otherwise indistinguishable from a slow tool.

Parameters
whatLabel for the wait log line (the tool being dispatched).
Returns
true when a shared hold was taken and must be released with unlock_shared(); false when this thread is the exclusive owner, which already excludes every re-rooting.
Version
2.13.0

The owner passing through is the point, not a shortcut: a sandboxed child's own tool calls run on the thread that entered the sandbox, and they are the calls that must see it. Anyone else who finds the lock held logs the wait before and after, so a stalled dispatch is visible.

Parameters
whatLabel for the wait log line.
Returns
true when a shared hold was taken; false for the owner. @req REQ-LOOP-009 @req REQ-DELEG-005
Version
2.13.0

Definition at line 64 of file tool_root_lock.cpp.

◆ owned_by_this_thread()

bool entropic::ToolRootLock::owned_by_this_thread ( ) const

Whether the calling thread holds the exclusive side.

Returns
true for the owner, false for every other thread.
Version
2.13.0
Returns
true for the owner, false for every other thread. @req REQ-LOOP-009
Version
2.13.0

Definition at line 92 of file tool_root_lock.cpp.

◆ unlock()

void entropic::ToolRootLock::unlock ( )

Release one exclusive level; the last one frees the lock.

Version
2.13.0

@req REQ-LOOP-009 @req REQ-DELEG-005

Version
2.13.0

Definition at line 43 of file tool_root_lock.cpp.

◆ unlock_shared()

void entropic::ToolRootLock::unlock_shared ( )

Release a shared hold taken by lock_shared() == true.

Version
2.13.0

@req REQ-LOOP-009

Version
2.13.0

Definition at line 82 of file tool_root_lock.cpp.


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