module Probatio::Waiters

def monow

def monow
  Process.clock_gettime(Process::CLOCK_MONOTONIC)
end

def wait_until(opts={}, &block)

def wait_until(opts={}, &block)
  timeout = opts[:timeout] || 14
  frequency = opts[:frequency] || 0.1
  start = Probatio.monow
  loop do
    sleep(frequency)
    #return if block.call == true
    r = block.call
    return r if r
    break if Probatio.monow - start > timeout
  end
  fail "timeout after #{timeout}s"
end