def pop
      @monitor.synchronize do
        if @events.empty?
          raise ThreadError, "queue empty" if @shutdown
          @resource.wait
        else
          delay = @events.first.at - Time.now
          @resource.wait(delay) if delay > 0
        end

        @events.shift
      end
    end
def pop
      @monitor.synchronize do
        if @events.empty?
          raise ThreadError, "queue empty" if @shutdown
          @resource.wait
        else
          delay = @events.first.at - Time.now
          @resource.wait(delay) if delay > 0
        end

        @events.shift
      end
    end
Wait until the queue has something due, pop it off the queue, and return
 it.

 Returns the popped event.