1 # -*- encoding: binary -*-
6 defined?(NeverBlock) or raise
9 # core namespace for all things that use Fibers in \Rainbows!
11 # It's generally not recommended to use any of this in your applications
12 # unless you're willing to accept breakage. Most of this is very
13 # difficult-to-use, fragile and we don't have much time to devote to
14 # supporting these in the future.
15 module Rainbows::Fiber
17 # blocked readers (key: fileno, value: Rainbows::Fiber::IO object)
20 # blocked writers (key: fileno, value: Rainbows::Fiber::IO object)
23 # sleeping fibers go here (key: Fiber object, value: wakeup time)
26 # puts the current Fiber into uninterruptible sleep for at least
27 # +seconds+. Unlike Kernel#sleep, this it is not possible to sleep
28 # indefinitely to be woken up (nobody wants that in a web server,
29 # right?). Calling this directly is deprecated, use
30 # Rainbows.sleep(seconds) instead.
31 def self.sleep(seconds)
32 ZZ[Fiber.current] = Rainbows.now + seconds
36 autoload :Base, 'rainbows/fiber/base'
37 autoload :Queue, 'rainbows/fiber/queue'
38 autoload :IO, 'rainbows/fiber/io'