public class ScheduledTask extends BasicTask<java.lang.Object>
Note that some termination logic, including BasicTask.addListener(Runnable, java.util.concurrent.Executor)
,
is not precisely defined.
BasicTask.SubmissionErrorCatchingExecutor, BasicTask.TaskFinalizer
TaskInternal.TaskCancellationMode
description, displayName, NO_OP, WARN_IF_NOT_RUN
Constructor and Description |
---|
ScheduledTask(java.util.concurrent.Callable<Task<?>> taskFactory) |
ScheduledTask(java.util.Map<?,?> flags,
java.util.concurrent.Callable<Task<?>> taskFactory) |
ScheduledTask(java.util.Map<?,?> flags,
Task<?> task) |
ScheduledTask(Task<?> task) |
Modifier and Type | Method and Description |
---|---|
void |
blockUntilEnded()
Causes calling thread to block until the task is ended.
|
void |
blockUntilFirstScheduleStarted() |
boolean |
blockUntilNextRunFinished(Duration timeout)
Internal method used to allow callers to wait for underlying tasks to finished in the case of cancellation.
|
ScheduledTask |
cancelOnException(boolean cancel) |
ScheduledTask |
delay(Duration d) |
ScheduledTask |
delay(long val) |
java.lang.Object |
get() |
java.util.concurrent.ScheduledFuture<?> |
getNextScheduled() |
int |
getRunCount() |
java.util.concurrent.Callable<Task<?>> |
getTaskFactory() |
boolean |
isDone()
As
Future.isDone() . |
ScheduledTask |
maxIterations(int val) |
Task<?> |
newTask() |
ScheduledTask |
period(Duration d) |
ScheduledTask |
period(long val) |
addListener, applyTagModifier, asTask, blockUntilEnded, blockUntilStarted, blockUntilStarted, cancel, cancel, cancel, equals, get, get, getBlockingDetails, getBlockingTask, getDescription, getDisplayName, getEndTimeUtc, getExtraStatusText, getId, getInternalFuture, getJob, getListeners, getMutableTags, getProxyTarget, getQueuedTimeUtc, getStartTimeUtc, getStatusDetail, getStatusSummary, getSubmittedByTask, getSubmitTimeUtc, getTags, getThread, getUnchecked, getUnchecked, hashCode, ignoreIfNotRun, initInternalFuture, isBegun, isCancelled, isError, isQueued, isQueuedAndNotSubmitted, isQueuedOrSubmitted, isSubmitted, markQueued, resetBlockingDetails, resetBlockingTask, runListeners, setBlockingDetails, setBlockingTask, setEndTimeUtc, setExtraStatusText, setFinalizer, setJob, setStartTimeUtc, setSubmittedByTask, setSubmitTimeUtc, setThread, toString, uncancel
public ScheduledTask(java.util.concurrent.Callable<Task<?>> taskFactory)
public ScheduledTask(Task<?> task)
public ScheduledTask(java.util.Map<?,?> flags, Task<?> task)
public ScheduledTask(java.util.Map<?,?> flags, java.util.concurrent.Callable<Task<?>> taskFactory)
public int getRunCount()
public java.util.concurrent.ScheduledFuture<?> getNextScheduled()
public ScheduledTask delay(Duration d)
public ScheduledTask delay(long val)
public ScheduledTask period(Duration d)
public ScheduledTask period(long val)
public ScheduledTask maxIterations(int val)
public ScheduledTask cancelOnException(boolean cancel)
public java.util.concurrent.Callable<Task<?>> getTaskFactory()
public Task<?> newTask()
public boolean isDone()
Task
Future.isDone()
. In particular if cancelled, this will return true
as soon as it is cancelled. The thread for this task may still be running,
if the cancellation (often an interruption, but may be weaker) has not applied,
and submitted threads may also be running depending on cancellation parameters.
Future.get()
is guaranteed to return immediately, throwing in the case of cancellation
prior to completion (and including the case above where a thread may still be running).
To check whether cancelled threads for this task have completed,
inspect Task.getEndTimeUtc()
, which is guaranteed to be set when threads complete
if the thread is started (as determinable by whether Task.getStartTimeUtc()
is set).
(The threads of submitted/child tasks will usually be independent; to determine their
completion requires inspecting the ExecutionManager
.)
public void blockUntilFirstScheduleStarted()
public void blockUntilEnded()
Task
Either normally or by cancellation or error, but without throwing error on cancellation or error. (Errors are logged at debug.)
blockUntilEnded
in interface Task<java.lang.Object>
blockUntilEnded
in class BasicTask<java.lang.Object>
public java.lang.Object get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
@Beta public boolean blockUntilNextRunFinished(Duration timeout)
timeout
- maximum time to wait