rainbows.git  about / heads / tags
Unicorn for sleepy apps and slow clients
blob a11623a56e3e901e20c098de9d0ea24ce490eb7c 271 bytes (raw)
$ git show HEAD:lib/rainbows/fiber/coolio/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::Coolio::Sleeper < Coolio::TimerWatcher

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

  def on_timer
    @f.resume
  end
end

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