public interface AsyncTask<C extends ApplicationContext> extends AsyncExecutable<C>, java.lang.Runnable, LocalCancellableTask, TaskIdHolder, Dumpable, SimpleLogSupport
ExecutorService
.Modifier and Type | Method and Description |
---|---|
<R> R |
awaitFinished()
Waits non-interruptibly until the task has finished.
|
<R> R |
awaitFinished(long timeout,
java.util.concurrent.TimeUnit unit)
Waits until the task has finished but runs in a TimeoutException if
it did not finish within the expected time.
|
void |
awaitStarted()
Waits until the task has actually started running.
|
void |
executeChildTask(AsyncTask childTask)
Runs the child-task in the default executor of the
ApplicationContext . |
void |
executeChildTask(AsyncTask childTask,
java.util.concurrent.ExecutorService pool)
Runs the child-task asynchronously as a task on it's own.
|
java.lang.Exception |
getError()
Returns the execution error of this task which is only available
if the task failed.
|
long |
getProcessingDuration()
Tells how long the task has been running since STARTED
|
boolean |
hasError()
Tells whether the task failed and contains an execution error
|
boolean |
isRegisterForCancel()
Tells whether this task should be registered for cancel within the
TaskManager . |
boolean |
isRunning()
Returns true from the time on the task has been submitted until it has finished.
|
void |
releaseStart()
Releases the task for execution after submission.
|
void |
setName(NlsKey trKey,
java.lang.Object... args)
Set name of task by translation.
|
void |
setReleaseTimeout(long releaseTimeoutMillis)
Defines a timeout for waiting on the release gate after having started.
|
TaskId |
submit()
Submits this task for execution to the default application thread pool
|
TaskId |
submit(java.util.concurrent.ExecutorService pool)
Submits this task for execution to the given thread pool
|
checkCancelled, checkForErrorAndRethrow, executeAsync, executeSubTask, getName, getResult, getRunStateFlag, getTaskId, getType, handleCancellation, handleFailure, isCancellable, notifyProceeded, setCancellable, setName, setResult, setRunStateFlag, sleepChecked
getApplicationContext
execute
addMonitor, clearMonitors, getMonitorCount, getMonitors, hasMonitor, removeMonitor
getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel
cancel
wasCancelled
getTaskId
toDumpString, toDumpString, toString, toString
void setName(NlsKey trKey, java.lang.Object... args)
void awaitStarted() throws java.lang.InterruptedException
java.lang.InterruptedException
<R> R awaitFinished()
java.lang.InterruptedException
<R> R awaitFinished(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
awaitFinished()
java.lang.Exception getError()
boolean hasError()
long getProcessingDuration()
boolean isRegisterForCancel()
TaskManager
.
If it is not registered, then it won't be cancellable any more.void setReleaseTimeout(long releaseTimeoutMillis)
releaseStart()
is being called
explicitly. This allows for getting the TaskId
on submit but having more control about the actual start
time of the task. By default the task does not wait on the release gate.releaseStart()
void releaseStart()
setReleaseTimeout(long)
void executeChildTask(AsyncTask childTask) throws java.lang.Exception
ApplicationContext
.java.lang.Exception
executeChildTask(AsyncTask, ExecutorService)
void executeChildTask(AsyncTask childTask, java.util.concurrent.ExecutorService pool) throws java.lang.Exception
RunStateFlag
with the main-task. As the child-task
runs in a different execution thread it has got it's own TaskId
which is added to the
main-TaskId. canceling the main-task in fact cancels the child-task too. During child-task execution
the monitor will receive CHILD_STARTED, CHILD_SUCCEEDED and CHILD_FINISHED notifications. Any
PROGRESS notifications in between are associated to the current child-task.java.lang.Exception
boolean isRunning()
TaskId submit(java.util.concurrent.ExecutorService pool) throws java.lang.Exception
java.lang.Exception
- if the pool is busyTaskId submit() throws java.lang.Exception
java.lang.Exception
- if the pool is busyCopyright © 2014 EsprIT-Systems. All Rights Reserved.