Top Description Fields Constructors Methods
com.github.benmanes.caffeine.cache

pack-priv final Class Pacer

extends Object
Class Inheritance
Static Imports
com.github.benmanes.caffeine.cache.Caffeine.ceilingPowerOfTwo, java.util.Objects.requireNonNull

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.
Author
[email protected] (Ben Manes)

Field Summary

Modifier and TypeField and Description
pack-priv @Nullable Future<?>
pack-priv long
pack-priv final Scheduler
pack-priv static final long

Constructor Summary

AccessConstructor and Description
pack-priv
Pacer(Scheduler scheduler)

Method Summary

Modifier and TypeMethod and Description
pack-priv long
calculateSchedule(long now, long delay, long scheduleAt)

Returns the delay and sets the next fire time.

public void
cancel()

Attempts to cancel execution of the scheduled task, if present.

public boolean
isScheduled()

Returns if a task is scheduled to run.

pack-priv boolean
maySkip(long scheduleAt)

Returns if the current fire time is sooner, or if it is later and within the tolerance limit.

public void
schedule(Executor executor, Runnable command, long now, long delay)

Schedules the task, pacing the execution if occurring too often.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

futureback to summary
pack-priv @Nullable Future<?> future
nextFireTimeback to summary
pack-priv long nextFireTime
schedulerback to summary
pack-priv final Scheduler scheduler
TOLERANCEback to summary
pack-priv static final long TOLERANCE

Constructor Detail

Pacerback to summary
pack-priv Pacer(Scheduler scheduler)

Method Detail

calculateScheduleback to summary
pack-priv long calculateSchedule(long now, long delay, long scheduleAt)

Returns the delay and sets the next fire time.

cancelback to summary
public void cancel()

Attempts to cancel execution of the scheduled task, if present.

isScheduledback to summary
public boolean isScheduled()

Returns if a task is scheduled to run.

maySkipback to summary
pack-priv boolean maySkip(long scheduleAt)

Returns if the current fire time is sooner, or if it is later and within the tolerance limit.

scheduleback to summary
public void schedule(Executor executor, Runnable command, long now, long delay)

Schedules the task, pacing the execution if occurring too often.