Class: LLM::Function::Fork::Group
- 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
- #alive? ⇒ Boolean
-
#initialize(tasks) ⇒ Group
constructor
A new instance of Group.
- #interrupt! ⇒ nil (also: #cancel!)
- #spawn ⇒ nil
- #wait ⇒ Array<LLM::Function::Return> (also: #value)
Constructor Details
#initialize(tasks) ⇒ Group
Returns a new instance of Group.
10 11 12 |
# File 'lib/llm/function/fork/group.rb', line 10 def initialize(tasks) @tasks = tasks end |
Instance Method Details
#alive? ⇒ 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!
31 32 33 34 |
# File 'lib/llm/function/fork/group.rb', line 31 def interrupt! @tasks.each(&:interrupt!) nil end |
#spawn ⇒ 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 |
#wait ⇒ Array<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 |