class Async::Reactor
def sleep(duration)
-
duration
(Numeric
) -- The time in seconds, to sleep for.
def sleep(duration) fiber = Fiber.current timer = self.after(duration) do if fiber.alive? fiber.resume end end Task.yield ensure timer.cancel if timer end