Class: LLM::Function::Fork::Group

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

Overview

Wraps an array of Task objects that are running in forked child processes.

Instance Method Summary collapse

Constructor Details

#initialize(tasks) ⇒ Group

Returns a new instance of Group.

Parameters:



10
11
12
# File 'lib/llm/function/fork/group.rb', line 10

def initialize(tasks)
  @tasks = tasks
end

Instance Method Details

#alive?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/llm/function/fork/group.rb', line 25

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

#interrupt!nil Also known as: cancel!

Returns:

  • (nil)


31
32
33
34
# File 'lib/llm/function/fork/group.rb', line 31

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

#spawnnil

Returns:

  • (nil)


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

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

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



39
40
41
42
# File 'lib/llm/function/fork/group.rb', line 39

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