Class: LLM::Function::Sequential::Group

Inherits:
Group
  • Object
show all
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

Constructor Details

#initialize(tasks) ⇒ LLM::Function::Sequential::Group

Parameters:



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

Returns:

  • (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!

Interrupts the thread blocked in #wait. Sequential functions run on the caller's thread, and this methods raises Interrupt on that thread.

Returns:

  • (nil)


42
43
44
45
# File 'lib/llm/function/sequential/group.rb', line 42

def interrupt!
  @owner&.raise(LLM::Interrupt)
  nil
end

#spawnnil

Returns:

  • (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

#waitArray<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