Class: LLM::Function::Task
- Inherits:
-
Object
- Object
- LLM::Function::Task
- Defined in:
- lib/llm/function/task.rb
Overview
The Task class wraps a single concurrent function call and provides a small, uniform interface across threads, fibers, and async tasks.
Instance Attribute Summary collapse
- #task ⇒ Object readonly
Instance Method Summary collapse
- #alive? ⇒ Boolean
- #initialize(task) ⇒ LLM::Function::Task constructor
- #wait ⇒ LLM::Function::Return (also: #value)
Constructor Details
#initialize(task) ⇒ LLM::Function::Task
15 16 17 |
# File 'lib/llm/function/task.rb', line 15 def initialize(task) @task = task end |
Instance Attribute Details
Instance Method Details
#alive? ⇒ Boolean
21 22 23 |
# File 'lib/llm/function/task.rb', line 21 def alive? task.alive? end |
#wait ⇒ LLM::Function::Return Also known as: value
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/llm/function/task.rb', line 27 def wait if Thread === task task.value elsif Fiber === task task.resume if task.alive? task.value else task.wait end end |