T - type of resultTError - type of errorpublic abstract class Task<T,TError extends Exception> extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Task.Cpu<T,TError extends Exception>
Task using only CPU resource.
|
static class |
Task.Done<T,TError extends Exception>
Task already done with a result or an error.
|
static class |
Task.OnFile<T,TError extends Exception>
Task using a only a file resource.
|
class |
Task.Output
Synchronization point holding the result or error of this task.
|
static class |
Task.Parameter<TParam,TResult,TError extends Exception>
Task holding a parameter.
|
static class |
Task.Unmanaged<TResult,TError extends Exception>
Unmanaged task that may use any resource and block at any time without using a synchronization point.
|
| Modifier and Type | Field and Description |
|---|---|
static byte |
NB_PRIORITES |
static byte |
PRIORITY_BACKGROUND |
static byte |
PRIORITY_IMPORTANT |
static byte |
PRIORITY_LOW |
static byte |
PRIORITY_NORMAL |
static byte |
PRIORITY_RATHER_IMPORTANT |
static byte |
PRIORITY_RATHER_LOW |
static byte |
PRIORITY_TOP |
static byte |
PRIORITY_URGENT |
static byte |
STATUS_BLOCKED
started but blocked (waiting for something).
|
static byte |
STATUS_DONE
done.
|
static byte |
STATUS_EXECUTED
executed, but some sub-tasks are not yet done.
|
static byte |
STATUS_NOT_STARTED
not yet started.
|
static byte |
STATUS_RUNNING
started and still running.
|
static byte |
STATUS_STARTED_READY
started and put in the ready list of the task manager.
|
static byte |
STATUS_STARTED_WAITING
started but waiting for a specific time.
|
protected JoinPoint<TError> |
taskJoin |
| Constructor and Description |
|---|
Task(Object resource,
String description,
byte priority)
Constructor.
|
Task(Object resource,
String description,
byte priority,
Consumer<Pair<T,TError>> ondone)
Constructor.
|
Task(TaskManager manager,
String description,
byte priority)
Constructor.
|
Task(TaskManager manager,
String description,
byte priority,
Consumer<Pair<T,TError>> ondone)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cancel(CancelException reason)
Cancel this task.
|
boolean |
cancelIfExecutionNotStarted(CancelException reason)
Cancel this task only if not yet started.
|
void |
changeNextExecutionTime(long time)
Change the next execution time of scheduled or repetitive task.
|
Task<T,TError> |
ensureUnblocked(IAsync<?>... sp)
Ensure that when this task will be done, successfully or not, the given synchronization point
are unblocked.
|
Task<T,TError> |
executeAgainAt(long time)
Execute again this task at the given time.
|
Task<T,TError> |
executeAgainIn(long delay)
Execute again this task in the given delay.
|
Task<T,TError> |
executeAt(long time)
Execute this task at the given time.
|
Task<T,TError> |
executeEvery(long delay,
long initialDelay)
Execute this task repeatedly.
|
Task<T,TError> |
executeIn(long delay)
Execute this task in the given delay in milliseconds.
|
void |
executeNextOccurenceNow()
Change the next execution time to now.
|
void |
executeNextOccurenceNow(byte priority)
Change the next execution time to now with the given priority.
|
Application |
getApplication() |
CancelException |
getCancelEvent() |
String |
getDescription() |
TError |
getError() |
long |
getMaxBlockingTimeInNanoBeforeToLog() |
Task.Output |
getOutput() |
byte |
getPriority() |
T |
getResult() |
byte |
getStatus() |
TaskManager |
getTaskManager() |
boolean |
hasError() |
boolean |
isCancelled() |
boolean |
isCancelling() |
boolean |
isDone() |
boolean |
isRunning() |
boolean |
isStarted() |
boolean |
isSuccessful() |
void |
ondone(Task<?,?> todo,
boolean evenIfErrorOrCancel)
Start the given task once this task is done.
|
abstract T |
run()
Method to implement to execute the task.
|
protected void |
setDescription(String descr) |
void |
setDone(T result,
TError error)
Set this task as done with the given result or error.
|
void |
setError(TError error)
Set this task's error (MUST NOT be started).
|
void |
setPriority(byte priority)
Change the priority of this task.
|
Task<T,TError> |
start()
Ask to start the task.
|
void |
startOn(boolean evenOnErrorOrCancel,
IAsync<?>... list)
Start this task once all the given synchronization points are unblocked.
|
void |
startOn(IAsync<? extends Exception> sp,
boolean evenOnErrorOrCancel)
Start this task once the given synchronization point is unblocked.
|
void |
startOnDone(Task<?,?> task)
Start this task once the given task is done.
|
void |
stopRepeat()
Do not execute this task again.
|
String |
toString() |
public static final byte PRIORITY_TOP
public static final byte PRIORITY_URGENT
public static final byte PRIORITY_IMPORTANT
public static final byte PRIORITY_RATHER_IMPORTANT
public static final byte PRIORITY_NORMAL
public static final byte PRIORITY_RATHER_LOW
public static final byte PRIORITY_LOW
public static final byte PRIORITY_BACKGROUND
public static final byte NB_PRIORITES
public static final byte STATUS_NOT_STARTED
public static final byte STATUS_STARTED_WAITING
public static final byte STATUS_STARTED_READY
public static final byte STATUS_RUNNING
public static final byte STATUS_BLOCKED
public static final byte STATUS_EXECUTED
public static final byte STATUS_DONE
public Task(TaskManager manager, String description, byte priority)
public Task(TaskManager manager, String description, byte priority, Consumer<Pair<T,TError>> ondone)
public Task(Object resource, String description, byte priority, Consumer<Pair<T,TError>> ondone)
public final byte getStatus()
public final String getDescription()
protected final void setDescription(String descr)
public final Application getApplication()
public final TaskManager getTaskManager()
public abstract T run() throws TError extends Exception, CancelException
TError extends ExceptionCancelExceptionpublic final Task<T,TError> start()
public final void cancel(CancelException reason)
public final boolean cancelIfExecutionNotStarted(CancelException reason)
public final void setError(TError error)
public final boolean isDone()
public final boolean isSuccessful()
public final boolean isCancelling()
public final boolean isCancelled()
public final boolean isStarted()
public final boolean isRunning()
public final T getResult()
public final TError getError()
public final CancelException getCancelEvent()
public final boolean hasError()
public final byte getPriority()
public final void setPriority(byte priority)
public final Task.Output getOutput()
public final Task<T,TError> ensureUnblocked(IAsync<?>... sp)
public final Task<T,TError> executeIn(long delay)
public final Task<T,TError> executeEvery(long delay, long initialDelay)
public final void stopRepeat()
public final Task<T,TError> executeAgainIn(long delay)
public final Task<T,TError> executeAgainAt(long time)
public final void changeNextExecutionTime(long time)
public final void executeNextOccurenceNow()
public final void executeNextOccurenceNow(byte priority)
public final void startOn(IAsync<? extends Exception> sp, boolean evenOnErrorOrCancel)
public final void startOn(boolean evenOnErrorOrCancel,
IAsync<?>... list)
public final void startOnDone(Task<?,?> task)
public final void setDone(T result, TError error)
public final void ondone(Task<?,?> todo, boolean evenIfErrorOrCancel)
public long getMaxBlockingTimeInNanoBeforeToLog()
Copyright © 2019. All rights reserved.