def timeout(secs, &block)
    return block.call if secs.nil? || secs.zero?            # skip timeout flow entirely for zero or nil
    thr = Thread.current                                    # reference to current thread to be used in timeout thread
    job = @scheduler.run_in(secs) { @on_timeout.call thr }  # schedule this thread to be timed out; should get cancelled if block completes on time
    return block.call                                       # do what you gotta do
  ensure                                                    #
    job.cancel! if job                                      # cancel the scheduled timeout job; if the block completed on time, this
  end
takes number of seconds to wait before timing out, and code block subject to time out