Class: FiberStream::Pipeline
- Inherits:
-
Object
- Object
- FiberStream::Pipeline
- Defined in:
- lib/fiber_stream/pipeline.rb
Class Method Summary collapse
-
.build(source, sink) ⇒ Object
:nodoc:.
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.
9 10 11 12 |
# File 'lib/fiber_stream/pipeline.rb', line 9 def initialize(source, sink) @source = source @sink = sink end |
Class Method Details
.build(source, sink) ⇒ Object
:nodoc:
5 6 7 |
# File 'lib/fiber_stream/pipeline.rb', line 5 def self.build(source, sink) # :nodoc: new(source, 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.
20 21 22 |
# File 'lib/fiber_stream/pipeline.rb', line 20 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.
31 32 33 34 35 |
# File 'lib/fiber_stream/pipeline.rb', line 31 def run_async validate_scheduler! RunningPipeline.start(Fiber.scheduler) { run } end |