class Roda::RodaPlugins::Streaming::Stream::Scheduler

The default scheduler to used when streaming, useful for code using ruby’s default threading support.

Public Class Methods

new(stream) click to toggle source

Store the stream to schedule.

# File lib/roda/plugins/streaming.rb, line 68
def initialize(stream)
  @stream = stream
end

Public Instance Methods

defer(*) { || ... } click to toggle source

Immediately yield.

# File lib/roda/plugins/streaming.rb, line 73
def defer(*)
  yield
end
schedule(*) { || ... } click to toggle source

Close the stream if there is an exception when scheduling, and reraise the exception if so.

# File lib/roda/plugins/streaming.rb, line 79
def schedule(*)
  yield
rescue Exception
  @stream.close
  raise
end