1 # -*- encoding: binary -*-
6 defined?(NeverBlock) or raise
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
19 # blocked readers (key: fileno, value: Rainbows::Fiber::IO object)
22 # blocked writers (key: fileno, value: Rainbows::Fiber::IO object)
25 # sleeping fibers go here (key: Fiber object, value: wakeup time)
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
39 autoload :Base, 'rainbows/fiber/base'
40 autoload :Queue, 'rainbows/fiber/queue'
41 autoload :IO, 'rainbows/fiber/io'