public Optional<Duration> timeLeftOrThrow() {
        return timeout.map(timeout -> {
            Duration passed = timePassed();
            Duration left = timeout.minus(passed);
            if (left.toMillis() <= 0) {
                throw new UncheckedTimeoutException("Time since start " + passed + " exceeds timeout " + timeout);
            }

            return left;
        });
    }
Returns the time until deadline, if there is one.

@return time until deadline. It's toMillis() is guaranteed to be positive.
@throws UncheckedTimeoutException if the deadline has been reached or passed.
vespajlib/src/main/java/com/yahoo/time/TimeBudget.java