ol.protocol53.deadline

Time budgets for protocol53 operations.

A deadline is a fixed point in the future that answers one question: has an operation run out of time? Callers usually pass a positive java.time.Duration under :timeout; the protocol53 facade converts it to the :deadline in normalized provider options. Callers may instead create a deadline when several operations must share one budget.

Deadlines are monotonic. They ride on System/nanoTime, so clock changes — NTP corrections, daylight saving, someone setting the system clock — cannot move them. That makes them reliable for timeouts and meaningless for anything else: a deadline is just a number that only makes sense inside the process that created it. Do not serialize it, store it, share it across processes, or compare it against wall-clock time.

Build one with after. Check it with remaining, expired?, and within?.

after

(after duration)

Returns a deadline that falls duration from now.

duration is a positive java.time.Duration; it must be shorter than Long/MAX_VALUE nanoseconds, roughly 292 years.

(deadline/after (java.time.Duration/ofSeconds 30))

remaining

(remaining operation-deadline)

Returns how much time is left before operation-deadline.

The value is a java.time.Duration that never goes negative; once the deadline has passed it is Duration/ZERO.


expired?

(expired? operation-deadline)

Returns true once operation-deadline has no time left.


within?

(within? operation-deadline duration)

Returns true when duration still fits before operation-deadline.

Use it to decide whether to start work that needs at least duration of budget. duration is a positive java.time.Duration.