Class: LLM::Function::Sequential::Group
- Defined in:
- lib/llm/function/sequential/group.rb
Overview
Wraps an array of Task objects
for sequential execution. Provides the same interface as
concurrent group wrappers so callers can flow through
task(strategy).wait regardless of the strategy being
used.
Instance Method Summary collapse
- #alive? ⇒ Boolean
- #initialize(tasks) ⇒ LLM::Function::Sequential::Group constructor
-
#interrupt! ⇒ nil
(also: #cancel!)
Interrupts the thread blocked in #wait.
- #spawn ⇒ nil
- #wait ⇒ Array<LLM::Function::Return> (also: #value)
Constructor Details
#initialize(tasks) ⇒ LLM::Function::Sequential::Group
15 16 17 18 |
# File 'lib/llm/function/sequential/group.rb', line 15 def initialize(tasks) @tasks = tasks @owner = nil end |
Instance Method Details
#alive? ⇒ Boolean
32 33 34 |
# File 'lib/llm/function/sequential/group.rb', line 32 def alive? @tasks.any?(&:alive?) end |
#interrupt! ⇒ nil Also known as: cancel!
42 43 44 45 |
# File 'lib/llm/function/sequential/group.rb', line 42 def interrupt! @owner&.raise(LLM::Interrupt) nil end |
#spawn ⇒ nil
22 23 24 25 26 27 28 |
# File 'lib/llm/function/sequential/group.rb', line 22 def spawn # no-op (execution happens in wait) @tasks.each(&:spawn) nil ensure @spawned = true end |
#wait ⇒ Array<LLM::Function::Return> Also known as: value
50 51 52 53 54 55 |
# File 'lib/llm/function/sequential/group.rb', line 50 def wait @owner = Thread.current @tasks.map(&:wait) ensure @owner = nil end |