Class: Roda::RodaPlugins::Streaming::Stream::Scheduler
- Inherits:
-
Object
- Object
- Roda::RodaPlugins::Streaming::Stream::Scheduler
- Defined in:
- lib/roda/plugins/streaming.rb
Overview
The default scheduler to used when streaming, useful for code using ruby’s default threading support.
Instance Method Summary collapse
-
#defer ⇒ Object
Immediately yield.
-
#initialize(stream) ⇒ Scheduler
constructor
Store the stream to schedule.
-
#schedule ⇒ Object
Close the stream if there is an exception when scheduling, and reraise the exception if so.
Constructor Details
#initialize(stream) ⇒ Scheduler
Store the stream to schedule.
68 69 70 |
# File 'lib/roda/plugins/streaming.rb', line 68 def initialize(stream) @stream = stream end |
Instance Method Details
#defer ⇒ Object
Immediately yield.
73 74 75 |
# File 'lib/roda/plugins/streaming.rb', line 73 def defer(*) yield end |
#schedule ⇒ Object
Close the stream if there is an exception when scheduling, and reraise the exception if so.
79 80 81 82 83 84 |
# File 'lib/roda/plugins/streaming.rb', line 79 def schedule(*) yield rescue Exception @stream.close raise end |