doc: stop recommending Fiber* stuff
[rainbows.git] / lib / rainbows / fiber.rb
blob34b7c394ca8974693238de34d3a1ddf5471616d1
1 # -*- encoding: binary -*-
2 # :stopdoc:
3 begin
4   require 'fiber'
5 rescue LoadError
6   defined?(NeverBlock) or raise
7 end
8 # :startdoc:
10 # core namespace for all things that use Fibers in \Rainbows!
12 # It's generally not recommended to use any of this in your applications
13 # unless you're willing to accept breakage.  Most of this is very
14 # difficult-to-use, fragile and we don't have much time to devote to
15 # supporting these in the future.
16 module Rainbows::Fiber
18   # :stopdoc:
19   # blocked readers (key: fileno, value: Rainbows::Fiber::IO object)
20   RD = []
22   # blocked writers (key: fileno, value: Rainbows::Fiber::IO object)
23   WR = []
25   # sleeping fibers go here (key: Fiber object, value: wakeup time)
26   ZZ = {}
27   # :startdoc:
29   # puts the current Fiber into uninterruptible sleep for at least
30   # +seconds+.  Unlike Kernel#sleep, this it is not possible to sleep
31   # indefinitely to be woken up (nobody wants that in a web server,
32   # right?).  Calling this directly is deprecated, use
33   # Rainbows.sleep(seconds) instead.
34   def self.sleep(seconds)
35     ZZ[Fiber.current] = Time.now + seconds
36     Fiber.yield
37   end
39   autoload :Base, 'rainbows/fiber/base'
40   autoload :Queue, 'rainbows/fiber/queue'
41   autoload :IO, 'rainbows/fiber/io'
42 end