def wait(timeout = nil)
      @mutex.lock

      unless @set
        remaining = Condition::Result.new(timeout)
        while !@set && remaining.can_wait?
          remaining = @condition.wait(@mutex, remaining.remaining_time)
        end
      end

      @set
    ensure
      @mutex.unlock
    end
def wait(timeout = nil)
      @mutex.lock

      unless @set
        remaining = Condition::Result.new(timeout)
        while !@set && remaining.can_wait?
          remaining = @condition.wait(@mutex, remaining.remaining_time)
        end
      end

      @set
    ensure
      @mutex.unlock
    end
Wait a given number of seconds for the `Event` to be set by another
 thread. Will wait forever when no `timeout` value is given. Returns
 immediately if the `Event` has already been set.

 @return [Boolean]
   true if the `Event` was set before timeout else false