Package com.hazelcast.scheduledexecutor
Interface IScheduledFuture<V>
- Type Parameters:
V
- The result type returned by this Future
- All Superinterfaces:
Comparable<Delayed>
,Delayed
,Future<V>
,ScheduledFuture<V>
A delayed result-bearing action that can be cancelled. Usually a scheduled future is the result of scheduling a task with a
IScheduledExecutorService
.
Enhances the default ScheduledFuture
API with support of statistics and time measurement info, through ScheduledTaskStatistics
-
Method Summary
Modifier and TypeMethodDescriptionboolean
cancel
(boolean mayInterruptIfRunning) Attempts to cancel further scheduling of this task.void
dispose()
Used to destroy the instance of theIScheduledFuture
in the scheduled executor.Returns the scheduled future resource handler.getStats()
Returns the statistics and time measurement info of the execution of this scheduled future in theIScheduledExecutorService
it was scheduled.Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface java.util.concurrent.Future
get, get, isCancelled, isDone
-
Method Details
-
getHandler
ScheduledTaskHandler getHandler()Returns the scheduled future resource handler. Can be used to re-acquire control of theIScheduledFuture
using theIScheduledExecutorService.getScheduledFuture(ScheduledTaskHandler)
- Returns:
- An instance of
ScheduledTaskHandler
, a resource handler for this scheduled future.
-
getStats
ScheduledTaskStatistics getStats()Returns the statistics and time measurement info of the execution of this scheduled future in theIScheduledExecutorService
it was scheduled.- Returns:
- An instance of
ScheduledTaskStatistics
, holding all statistics and measurements
-
dispose
void dispose()Used to destroy the instance of theIScheduledFuture
in the scheduled executor. Once the instance is destroyed, any subsequent action on theIScheduledFuture
will fail with anIllegalStateException
Attempting to re-create theIScheduledFuture
from theIScheduledExecutorService.getScheduledFuture(ScheduledTaskHandler)
using thegetHandler()
will succeed, but any subsequent access on that new future, will also fail withStaleTaskException
-
cancel
boolean cancel(boolean mayInterruptIfRunning) Attempts to cancel further scheduling of this task. This attempt will fail if the task has already completed, has already been cancelled, or could not be cancelled for some other reason. If successful, and this task has not started whencancel
is called, this task should never run.Warning: This cancel will not attempt to interrupt the running thread if the task is already in progress, will just cancel further scheduling.
After this method returns, subsequent calls to
Future.isDone()
will always returntrue
. Subsequent calls toFuture.isCancelled()
will always returntrue
if this method returnedtrue
.- Specified by:
cancel
in interfaceFuture<V>
- Parameters:
mayInterruptIfRunning
- is throwingUnsupportedOperationException
- Returns:
false
if the task could not be cancelled, typically because it has already completed normally;true
otherwise
-