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
-
#initialize(tasks) ⇒
LLM::Function::TaskGroup constructor
Creates a new TaskGroup from an array of async task objects.
-
#alive? ⇒
Boolean
Returns whether any task in the group is still alive.
-
#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 |
#wait ⇒ Array<LLM::Function::Return> Also known as: value
84 85 86 |
# File 'lib/llm/function/task_group.rb', line 84 def wait @tasks.map(&:wait) end |