|
Entropic 2.14.3
Local-first agentic inference engine
|
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. | |
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.
Definition at line 64 of file tool_root_lock.h.
| void entropic::ToolRootLock::lock | ( | ) |
Acquire exclusively; re-entrant for the owning thread.
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
Definition at line 26 of file tool_root_lock.cpp.
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.
| what | Label for the wait log line (the tool being dispatched). |
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.
| what | Label for the wait log line. |
Definition at line 64 of file tool_root_lock.cpp.
| bool entropic::ToolRootLock::owned_by_this_thread | ( | ) | const |
Whether the calling thread holds the exclusive side.
Definition at line 92 of file tool_root_lock.cpp.
| void entropic::ToolRootLock::unlock | ( | ) |
Release one exclusive level; the last one frees the lock.
@req REQ-LOOP-009 @req REQ-DELEG-005
Definition at line 43 of file tool_root_lock.cpp.
| void entropic::ToolRootLock::unlock_shared | ( | ) |
Release a shared hold taken by lock_shared() == true.
@req REQ-LOOP-009
Definition at line 82 of file tool_root_lock.cpp.