Class Pacer
java.lang.Object
com.github.benmanes.caffeine.cache.Pacer
A pacing scheduler that prevents executions from happening too frequently. Only one task may be
scheduled at any given time, the earliest pending task takes precedence, and the delay may be
increased if it is less than a tolerance threshold.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) long
calculateSchedule
(long now, long delay, long scheduleAt) Returns the delay and sets the next fire time.void
cancel()
Attempts to cancel execution of the scheduled task, if present.(package private) boolean
maySkip
(long scheduleAt) Returns if the current fire time is sooner, or if it is later and within the tolerance limit.void
Schedules the task, pacing the execution if occurring too often.
-
Field Details
-
TOLERANCE
static final long TOLERANCE -
scheduler
-
nextFireTime
long nextFireTime -
future
@Nullable Future<?> future
-
-
Constructor Details
-
Pacer
Pacer(Scheduler scheduler)
-
-
Method Details
-
schedule
Schedules the task, pacing the execution if occurring too often. -
cancel
public void cancel()Attempts to cancel execution of the scheduled task, if present. -
maySkip
boolean maySkip(long scheduleAt) Returns if the current fire time is sooner, or if it is later and within the tolerance limit. -
calculateSchedule
long calculateSchedule(long now, long delay, long scheduleAt) Returns the delay and sets the next fire time.
-