Class: Roda::RodaPlugins::Streaming::Stream::Scheduler

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(stream) ⇒ Scheduler

Store the stream to schedule.



70
71
72
# File 'lib/roda/plugins/streaming.rb', line 70

def initialize(stream)
  @stream = stream
end

Instance Method Details

#deferObject

Immediately yield.



75
76
77
# File 'lib/roda/plugins/streaming.rb', line 75

def defer(*)
  yield
end

#scheduleObject

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



81
82
83
84
85
86
# File 'lib/roda/plugins/streaming.rb', line 81

def schedule(*)
  yield
rescue Exception
  @stream.close
  raise
end