Class: LLM::Function::TaskGroup
- Inherits:
-
Object
- Object
- LLM::Function::TaskGroup
- Defined in:
- lib/llm/function/task_group.rb
Overview
The TaskGroup class wraps an array of Async::Task objects that are running LLM::Function calls concurrently using the async gem.
This class provides the same interface as ThreadGroup but uses async tasks for lightweight concurrency with automatic scheduling and I/O management.
Instance Method Summary collapse
-
#alive? ⇒ Boolean
Returns whether any task in the group is still alive.
-
#initialize(tasks) ⇒ LLM::Function::TaskGroup
constructor
Creates a new TaskGroup from an array of async task objects.
- #interrupt! ⇒ nil (also: #cancel!)
-
#wait ⇒ Array<LLM::Function::Return>
(also: #value)
Waits for all tasks in the group to finish and returns their Return values.
Constructor Details
#initialize(tasks) ⇒ LLM::Function::TaskGroup
Creates a new LLM::Function::TaskGroup from an array of async task objects.
34 35 36 |
# File 'lib/llm/function/task_group.rb', line 34 def initialize(tasks) @tasks = tasks end |
Instance Method Details
#alive? ⇒ Boolean
Returns whether any task in the group is still alive.
This method checks if any of the tasks in the group are still running. It can be useful for monitoring concurrent tool execution without blocking.
59 60 61 |
# File 'lib/llm/function/task_group.rb', line 59 def alive? @tasks.any?(&:alive?) end |
#interrupt! ⇒ nil Also known as: cancel!
65 66 67 68 |
# File 'lib/llm/function/task_group.rb', line 65 def interrupt! @tasks.each(&:interrupt!) nil end |
#wait ⇒ Array<LLM::Function::Return> Also known as: value
92 93 94 |
# File 'lib/llm/function/task_group.rb', line 92 def wait @tasks.map(&:wait) end |