Class: LLM::Function::Thread::Group

Inherits:
Group
  • Object
show all
Defined in:
lib/llm/function/thread/group.rb

Overview

Wraps an array of Task objects for concurrent thread-based execution. Interrupts all tasks and waits for them to complete.

Instance Method Summary collapse

Constructor Details

#initialize(tasks) ⇒ Group

Returns a new instance of Group.

Parameters:



11
12
13
# File 'lib/llm/function/thread/group.rb', line 11

def initialize(tasks)
  @tasks = tasks
end

Instance Method Details

#alive?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/llm/function/thread/group.rb', line 26

def alive?
  @tasks.any?(&:alive?)
end

#interrupt!nil Also known as: cancel!

Returns:

  • (nil)


32
33
34
35
# File 'lib/llm/function/thread/group.rb', line 32

def interrupt!
  @tasks.each(&:interrupt!)
  nil
end

#spawnnil

Returns:

  • (nil)


17
18
19
20
21
22
# File 'lib/llm/function/thread/group.rb', line 17

def spawn
  @tasks.each(&:spawn)
  nil
ensure
  @spawned = true
end

#waitArray<LLM::Function::Return> Also known as: value



40
41
42
43
# File 'lib/llm/function/thread/group.rb', line 40

def wait
  spawn unless @spawned
  @tasks.map(&:wait)
end