Class: FiberStream::Pipeline
- Inherits:
-
Object
- Object
- FiberStream::Pipeline
- Defined in:
- lib/fiber_stream/pipeline.rb
Instance Method Summary collapse
-
#initialize(source, sink) ⇒ Pipeline
constructor
A new instance of Pipeline.
-
#run ⇒ Object
Runs this pipeline in the current fiber.
-
#run_async ⇒ Object
Runs this pipeline in a scheduler-backed background fiber.
Constructor Details
#initialize(source, sink) ⇒ Pipeline
Returns a new instance of Pipeline.
5 6 7 8 |
# File 'lib/fiber_stream/pipeline.rb', line 5 def initialize(source, sink) @source = source @sink = sink end |
Instance Method Details
#run ⇒ Object
Runs this pipeline in the current fiber.
This is equivalent to ‘source.run_with(sink)` for the source and sink definitions captured by `Source#to`. Repeated runs create new materializations, subject to the replayability and resource ownership semantics of the captured endpoints.
16 17 18 |
# File 'lib/fiber_stream/pipeline.rb', line 16 def run @source.run_with(@sink) end |
#run_async ⇒ Object
Runs this pipeline in a scheduler-backed background fiber.
The method starts one new materialization and returns a ‘RunningPipeline` handle that can wait for the materialized value, observe completion, and request cancellation. Starting background execution requires an installed `Fiber.scheduler` from a non-blocking current fiber. FiberStream does not depend on Async at runtime.
27 28 29 30 31 |
# File 'lib/fiber_stream/pipeline.rb', line 27 def run_async validate_scheduler! RunningPipeline.__send__(:new, Fiber.scheduler) { run } end |