Class: ClaudeAgentSDK::FiberBoundary::SchedulingScope Private

Inherits:
Object
  • Object
show all
Defined in:
lib/claude_agent_sdk/fiber_boundary.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

The value stored under SCHEDULING_KEY: a closable carrier rather than a bare symbol. Fiber-storage inheritance copies the storage HASH but shares value REFERENCES, so every fiber (and thread) created during a dispatch inherits this same object. Restoring the dispatching fiber's own slot is therefore not enough — a child task spawned inside a handler that outlives the dispatch would keep reading the stale mode forever. Closing the scope in the dispatch's ensure invalidates it for ALL inheritors at once; readers fall back to the server's own default. Benign race on close vs. a concurrent reader: either value is a defensible mode for a call that straddles the dispatch boundary. Also carries the session's callback wrapper — the two travel (and are invalidated) together, so a descendant that outlives the dispatch can neither run with the session's mode nor with its wrapper.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mode, wrapper = nil) ⇒ SchedulingScope

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of SchedulingScope.



118
119
120
121
122
# File 'lib/claude_agent_sdk/fiber_boundary.rb', line 118

def initialize(mode, wrapper = nil)
  @mode = mode
  @wrapper = wrapper
  @active = true
end

Instance Attribute Details

#modeObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



116
117
118
# File 'lib/claude_agent_sdk/fiber_boundary.rb', line 116

def mode
  @mode
end

#wrapperObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



116
117
118
# File 'lib/claude_agent_sdk/fiber_boundary.rb', line 116

def wrapper
  @wrapper
end

Instance Method Details

#active?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


124
125
126
# File 'lib/claude_agent_sdk/fiber_boundary.rb', line 124

def active?
  @active
end

#closeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



128
129
130
# File 'lib/claude_agent_sdk/fiber_boundary.rb', line 128

def close
  @active = false
end