rainbows.git  about / heads / tags
Unicorn for sleepy apps and slow clients
blob 51f45279adbb15e1a33c01c3491c0f763bf0e41b 262 bytes (raw)
$ git show v2.0.0:lib/rainbows/fiber/rev/sleeper.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
 
# -*- encoding: binary -*-
# :enddoc:
class Rainbows::Fiber::Rev::Sleeper < Rev::TimerWatcher

  def initialize(seconds)
    @f = Fiber.current
    super(seconds, false)
    attach(Rev::Loop.default)
    Fiber.yield
  end

  def on_timer
    @f.resume
  end
end

git clone https://yhbt.net/rainbows.git