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,
RunnableWithParameter<Pair<T,TError>> ondone)
Constructor.
|
Task(TaskManager manager,
String description,
byte priority)
Constructor.
|
Task(TaskManager manager,
String description,
byte priority,
RunnableWithParameter<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(ISynchronizationPoint<?>... sp)
Ensure that when this task will be done, successfully or not, the given synchronization point
are unblocked.
|
void |
executeAgainAt(long time)
Execute again this task at the given time.
|
void |
executeAgainIn(long delay)
Execute again this task in the given delay.
|
void |
executeAt(long time)
Execute this task at the given time.
|
void |
executeEvery(long delay,
long initialDelay)
Execute this task repetively.
|
void |
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() |
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 |
setPriority(byte priority)
Change the priority of this task.
|
Task<T,TError> |
start()
Ask to start the task.
|
void |
startOn(boolean evenOnErrorOrCancel,
ISynchronizationPoint<?>... list)
Start this task once all the given synchronization points are unblocked.
|
void |
startOn(ISynchronizationPoint<? extends Exception> sp,
boolean evenOnErrorOrCancel)
Start this task once the given synchronization point is unblocked.
|
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, RunnableWithParameter<Pair<T,TError>> ondone)
public Task(Object resource, String description, byte priority, RunnableWithParameter<Pair<T,TError>> ondone)
public byte getStatus()
public String getDescription()
protected void setDescription(String descr)
public Application getApplication()
public TaskManager getTaskManager()
public abstract T run() throws TError extends Exception, CancelException
TError extends ExceptionCancelExceptionpublic Task<T,TError> start()
public void cancel(CancelException reason)
public boolean cancelIfExecutionNotStarted(CancelException reason)
public boolean isDone()
public boolean isSuccessful()
public boolean isCancelling()
public boolean isCancelled()
public boolean isStarted()
public boolean isRunning()
public T getResult()
public TError getError()
public CancelException getCancelEvent()
public boolean hasError()
public byte getPriority()
public void setPriority(byte priority)
public Task.Output getOutput()
public Task<T,TError> ensureUnblocked(ISynchronizationPoint<?>... sp)
public void executeAt(long time)
public void executeIn(long delay)
public void executeEvery(long delay,
long initialDelay)
public void stopRepeat()
public void executeAgainIn(long delay)
public void executeAgainAt(long time)
public void changeNextExecutionTime(long time)
public void executeNextOccurenceNow()
public void executeNextOccurenceNow(byte priority)
public void startOn(ISynchronizationPoint<? extends Exception> sp, boolean evenOnErrorOrCancel)
public void startOn(boolean evenOnErrorOrCancel,
ISynchronizationPoint<?>... list)
public void setDone(T result, TError error)
public void ondone(Task<?,?> todo, boolean evenIfErrorOrCancel)
Copyright © 2017. All rights reserved.