Interface PrioritisedExecutor.PrioritisedTask
- All Superinterfaces:
Cancellable
- Enclosing interface:
PrioritisedExecutor
-
Method Summary
Modifier and TypeMethodDescriptionbooleancancel()Forces this task to be marked as completed.booleanexecute()Executes this task.Returns the executor associated with this task.Returns the current priority.longReturns the suborder id associated with this task.booleanisQueued()Returns whether this task has been queued and is not completing.booleanlowerPriority(Priority priority) Attempts to lower the priority to the priority level specified.booleanlowerSubOrder(long subOrder) Attempts to lower the suborder to the suborder specified.booleanqueue()Causes a lazily queued task to become queued or executedbooleanraisePriority(Priority priority) Attempts to raise the priority to the priority level specified.booleanraiseSubOrder(long subOrder) Attempts to raise the suborder to the suborder specified.booleansetPriority(Priority priority) Attempts to set this task's priority level to the level specified.booleansetPriorityAndSubOrder(Priority priority, long subOrder) Sets the priority and suborder id associated with this task.booleansetSubOrder(long subOrder) Sets the suborder id associated with this task.
-
Method Details
-
getExecutor
PrioritisedExecutor getExecutor()Returns the executor associated with this task.- Returns:
- The executor associated with this task.
-
queue
boolean queue()Causes a lazily queued task to become queued or executed- Returns:
trueIf the task was queued,falseif the task was already queued/cancelled/executed- Throws:
IllegalStateException- If the backing executor has shutdown
-
isQueued
boolean isQueued()Returns whether this task has been queued and is not completing.- Returns:
trueIf the task has been queued,falseif the task has not been queued or is marked as completing.
-
cancel
boolean cancel()Forces this task to be marked as completed.- Specified by:
cancelin interfaceCancellable- Returns:
trueif the task was cancelled,falseif the task has already completed or is being completed.
-
execute
boolean execute()Executes this task. This will also mark the task as completing.Exceptions thrown from the runnable will be rethrown.
- Returns:
trueif this task was executed,falseif it was already marked as completed.
-
getPriority
Priority getPriority()Returns the current priority. Note thatPriority.COMPLETINGwill be returned if this task is completing or has completed. -
setPriority
Attempts to set this task's priority level to the level specified.- Parameters:
priority- Specified priority level.- Returns:
trueif successful,falseif this task is completing or has completed or the queue this task was scheduled on was shutdown, or if the priority was already at the specified level.- Throws:
IllegalArgumentException- If the priority is invalid
-
raisePriority
Attempts to raise the priority to the priority level specified.- Parameters:
priority- Priority specified- Returns:
falseif the current task is completing,trueif the priority was raised to the specified level or was already at the specified level or higher.- Throws:
IllegalArgumentException- If the priority is invalid
-
lowerPriority
Attempts to lower the priority to the priority level specified.- Parameters:
priority- Priority specified- Returns:
falseif the current task is completing,trueif the priority was lowered to the specified level or was already at the specified level or lower.- Throws:
IllegalArgumentException- If the priority is invalid
-
getSubOrder
long getSubOrder()Returns the suborder id associated with this task.- Returns:
- The suborder id associated with this task.
-
setSubOrder
boolean setSubOrder(long subOrder) Sets the suborder id associated with this task. Ths function has no effect when this task is completing or is completed.- Parameters:
subOrder- Specified new sub order.- Returns:
trueif successful,falseif this task is completing or has completed or the queue this task was scheduled on was shutdown, or if the current suborder is the same as the new sub order.
-
raiseSubOrder
boolean raiseSubOrder(long subOrder) Attempts to raise the suborder to the suborder specified.- Parameters:
subOrder- Specified new sub order.- Returns:
falseif the current task is completing,trueif the suborder was raised to the specified suborder or was already at the specified suborder or higher.
-
lowerSubOrder
boolean lowerSubOrder(long subOrder) Attempts to lower the suborder to the suborder specified.- Parameters:
subOrder- Specified new sub order.- Returns:
falseif the current task is completing,trueif the suborder was lowered to the specified suborder or was already at the specified suborder or lower.
-
setPriorityAndSubOrder
Sets the priority and suborder id associated with this task. Ths function has no effect when this task is completing or is completed.- Parameters:
priority- Priority specifiedsubOrder- Specified new sub order.- Returns:
trueif successful,falseif this task is completing or has completed or the queue this task was scheduled on was shutdown, or if the current priority and suborder are the same as the parameters.
-