From fa622de470d475f0afc94cb619cc69e7e127830c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 22 Dec 2009 01:22:32 -0800 Subject: common Rainbows.sleep(nr) method We'll export this across the board to all Rack applications to sleep with. This provides the optimum method of sleeping regardless of the concurrency model you choose. This method is still highly not recommended for pure event-driven models like Rev or EventMachine (but the threaded/fiber/actor-based variants are fine). --- lib/rainbows/fiber/base.rb | 3 ++- lib/rainbows/fiber/rev.rb | 6 ------ 2 files changed, 2 insertions(+), 7 deletions(-) (limited to 'lib/rainbows/fiber') diff --git a/lib/rainbows/fiber/base.rb b/lib/rainbows/fiber/base.rb index 1617c54..090a9e4 100644 --- a/lib/rainbows/fiber/base.rb +++ b/lib/rainbows/fiber/base.rb @@ -16,7 +16,8 @@ module Rainbows # puts the current Fiber into uninterruptible sleep for at least # +seconds+. Unlike Kernel#sleep, this it is not possible to sleep # indefinitely to be woken up (nobody wants that in a web server, - # right?). + # right?). Calling this directly is deprecated, use + # Rainbows.sleep(seconds) instead. def self.sleep(seconds) ZZ[::Fiber.current] = Time.now + seconds ::Fiber.yield diff --git a/lib/rainbows/fiber/rev.rb b/lib/rainbows/fiber/rev.rb index 36a46d4..bd9638f 100644 --- a/lib/rainbows/fiber/rev.rb +++ b/lib/rainbows/fiber/rev.rb @@ -108,12 +108,6 @@ module Rainbows::Fiber client.close end end - - # TODO: env["rainbows.sleep"] - def self.sleep(seconds) - Sleeper.new(seconds) - end - end class IO # see rainbows/fiber/io for original definition -- cgit v1.2.3-24-ge0c7