lib/quack_concurrency/sleeper.rb
def sleep(timeout = nil)
      timeout = process_timeout(timeout)
      enforce_sleep_call_limit
      @mutex.synchronize do
        timer do
          @condition_variable.wait(@mutex, timeout) unless @wake_called
        end
      end
    end
def sleep(timeout = nil)
      timeout = process_timeout(timeout)
      enforce_sleep_call_limit
      @mutex.synchronize do
        timer do
          @condition_variable.wait(@mutex, timeout) unless @wake_called
        end
      end
    end
Creates a new {Sleeper} concurrency tool.
 @return [Sleeper]
 Puts this thread to sleep.
 Will be skipped if {#wake} has already been called.
 If called without a timeout it will sleep forever.
 It can only be called once.
 @param timeout [nil,Numeric] maximum time to sleep in seconds, +nil+ for forever
 @raise [TypeError] if +timeout+ is not +nil+ or +Numeric+
 @raise [ArgumentError] if +timeout+ is negative
 @raise [RuntimeError] if already called once
 @raise [Exception] any exception raised by +ConditionVariable#wait+ (eg. interrupts, +ThreadError+)
 @return [Float] duration of time the thread was asleep in seconds