Class: ClaudeAgentSDK::Query::ThreadWaiter
- Inherits:
-
Object
- Object
- ClaudeAgentSDK::Query::ThreadWaiter
- Defined in:
- lib/claude_agent_sdk/query.rb
Overview
Waiter for control responses awaited OFF the reactor — i.e. a control method called from inside a hook/can_use_tool/SDK-MCP callback, which runs on a FiberBoundary worker thread (Python supports this reentrancy natively: callbacks are event-loop tasks and anyio.Event is level-triggered). Duck-types Async::Condition#signal for the read loop’s signal sites; the unconditional token push makes it level-triggered, closing the check-then-wait gap that an edge-triggered Condition would lose across threads.
Instance Method Summary collapse
-
#initialize ⇒ ThreadWaiter
constructor
A new instance of ThreadWaiter.
- #signal(_value = nil) ⇒ Object
- #wait(timeout) ⇒ Object
Constructor Details
#initialize ⇒ ThreadWaiter
Returns a new instance of ThreadWaiter.
35 36 37 |
# File 'lib/claude_agent_sdk/query.rb', line 35 def initialize @queue = ::Queue.new end |
Instance Method Details
#signal(_value = nil) ⇒ Object
39 40 41 |
# File 'lib/claude_agent_sdk/query.rb', line 39 def signal(_value = nil) @queue << true end |
#wait(timeout) ⇒ Object
43 44 45 |
# File 'lib/claude_agent_sdk/query.rb', line 43 def wait(timeout) @queue.pop(timeout: timeout) end |