class EmmyHttp::Timer

Attributes

interval[RW]

Public Class Methods

new(interval) click to toggle source
# File lib/emmy_http/timer.rb, line 8
def initialize(interval)
  @interval = interval
end

Public Instance Methods

await() click to toggle source
# File lib/emmy_http/timer.rb, line 18
def await
  Fiber.await do |fiber|
    # create connection
    start

    on :timeout do
      fiber.resume true
    end
  end
end
start() click to toggle source
# File lib/emmy_http/timer.rb, line 12
def start
  EmmyMachine.timeout(interval) do
    timeout!
  end
end