class Async::Reactor

def sleep(duration)

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