Package org.exoplatform.bluemind.client
Class BlueMindCallBudget
java.lang.Object
org.exoplatform.bluemind.client.BlueMindCallBudget
- All Implemented Interfaces:
AutoCloseable
One overall time budget for the BlueMind calls made on one thread, set by a
caller whose own time is bounded — a landing of a mail's invitation, which
holds the user's click: every exchange
BlueMindRestClient sends while
it is open waits the smaller of the client's request timeout and the time
left, and none is sent once nothing is left. The wait covers the whole
exchange, body included.
Opened with start(java.time.Duration), closed with close() — a try-with-resources
— and per thread: a call made on another thread is not bounded by it.
Opening one inside another keeps the earlier end when it is the sooner.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the budget: the thread's previous one, if any, applies again.static BlueMindCallBudgetOpens a budget on the current thread.
-
Method Details
-
start
Opens a budget on the current thread.- Parameters:
budget- the time the calls made untilclose()may take altogether; null or negative is none left- Returns:
- the budget, to close
-
close
public void close()Closes the budget: the thread's previous one, if any, applies again.- Specified by:
closein interfaceAutoCloseable
-