Class: LLM::Function::Async::Group
- Defined in:
- lib/llm/function/async/group.rb
Overview
Instance Method Summary collapse
- #alive? ⇒ Boolean
-
#initialize(tasks, options = {}) ⇒ Group
constructor
A new instance of Group.
- #interrupt! ⇒ nil (also: #cancel!)
- #spawn ⇒ nil
- #wait ⇒ Array<LLM::Function::Return> (also: #value)
Constructor Details
Instance Method Details
#alive? ⇒ Boolean
32 33 34 |
# File 'lib/llm/function/async/group.rb', line 32 def alive? @tasks.any?(&:alive?) end |
#interrupt! ⇒ nil Also known as: cancel!
38 39 40 41 |
# File 'lib/llm/function/async/group.rb', line 38 def interrupt! @tasks.each(&:interrupt!) nil end |
#spawn ⇒ nil
20 21 22 23 24 25 26 27 28 |
# File 'lib/llm/function/async/group.rb', line 20 def spawn @tasks.each do |task| task.reactor = @reactor task.spawn end nil ensure @spawned = true end |
#wait ⇒ Array<LLM::Function::Return> Also known as: value
46 47 48 49 50 51 |
# File 'lib/llm/function/async/group.rb', line 46 def wait spawn unless @spawned @tasks.map(&:wait) ensure @reactor.stop end |