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

public Interface Scheduler

Additional top-level classes in compilation unit: SystemScheduler, ExecutorServiceScheduler, GuardedScheduler, DisabledScheduler, DisabledFuture.

Known Direct Implementers
com.github.benmanes.caffeine.cache.SystemScheduler, com.github.benmanes.caffeine.cache.ExecutorServiceScheduler, com.github.benmanes.caffeine.cache.GuardedScheduler, com.github.benmanes.caffeine.cache.DisabledScheduler
Annotations
@FunctionalInterface
Static Imports
java.util.Objects.requireNonNull

A scheduler that submits a task to an executor after a given delay.
Author
[email protected] (Ben Manes)

Method Summary

Modifier and TypeMethod and Description
public static Scheduler

Returns:

a scheduler that always returns a successfully completed future
disabledScheduler
()

Returns a scheduler that always returns a successfully completed future.

public static Scheduler

Returns:

a scheduler that delegates to the a ScheduledExecutorService
forScheduledExecutorService
(ScheduledExecutorService
the executor to schedule on
scheduledExecutorService
)

Returns a scheduler that delegates to the a ScheduledExecutorService.

public static Scheduler

Returns:

a scheduler that suppresses and logs any exception thrown by the delegate
guardedScheduler
(Scheduler
the scheduler to delegate to
scheduler
)

Returns a scheduler that suppresses and logs any exception thrown by the delegate scheduler.

public Future<?>

Returns:

a scheduled future representing the pending submission of the task
schedule
(Executor
the executor to run the task
executor
,
Runnable
the runnable task to schedule
command
,
long
how long to delay, in units of unit
delay
,
TimeUnit
a TimeUnit determining how to interpret the delay parameter
unit
)

Returns a future that will submit the task to the executor after the given delay.

public static Scheduler

Returns:

a scheduler that uses the system-wide scheduling thread
systemScheduler
()

Returns a scheduler that uses the system-wide scheduling thread by using CompletableFuture#delayedExecutor.

Method Detail

disabledSchedulerback to summary
public static Scheduler disabledScheduler()

Returns a scheduler that always returns a successfully completed future.

Returns:Scheduler

a scheduler that always returns a successfully completed future

forScheduledExecutorServiceback to summary
public static Scheduler forScheduledExecutorService(ScheduledExecutorService scheduledExecutorService)

Returns a scheduler that delegates to the a ScheduledExecutorService.

Parameters
scheduledExecutorService:ScheduledExecutorService

the executor to schedule on

Returns:Scheduler

a scheduler that delegates to the a ScheduledExecutorService

guardedSchedulerback to summary
public static Scheduler guardedScheduler(Scheduler scheduler)

Returns a scheduler that suppresses and logs any exception thrown by the delegate scheduler.

Parameters
scheduler:Scheduler

the scheduler to delegate to

Returns:Scheduler

a scheduler that suppresses and logs any exception thrown by the delegate

scheduleback to summary
public Future<?> schedule(Executor executor, Runnable command, long delay, TimeUnit unit)

Returns a future that will submit the task to the executor after the given delay.

Parameters
executor:Executor

the executor to run the task

command:Runnable

the runnable task to schedule

delay:long

how long to delay, in units of unit

unit:TimeUnit

a TimeUnit determining how to interpret the delay parameter

Returns:Future<?>

a scheduled future representing the pending submission of the task

systemSchedulerback to summary
public static Scheduler systemScheduler()

Returns a scheduler that uses the system-wide scheduling thread by using CompletableFuture#delayedExecutor.

Returns:Scheduler

a scheduler that uses the system-wide scheduling thread