Interface PrioritisedExecutor.PrioritisedTask

All Superinterfaces:
Cancellable
Enclosing interface:
PrioritisedExecutor

public static interface PrioritisedExecutor.PrioritisedTask extends Cancellable
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Forces this task to be marked as completed.
    boolean
    Executes this task.
    Returns the executor associated with this task.
    Returns the current priority.
    Atomically retrieves the priority, suborder, and stream for this task.
    long
    Returns the stream id associated with this task, or 0 if completing.
    long
    Returns the suborder id associated with this task, or 0 if completing.
    boolean
    Returns whether this task has been queued and is not completing.
    boolean
    Attempts to lower the priority to the priority level specified.
    boolean
    lowerSubOrder(long subOrder)
    Attempts to lower the suborder to the suborder specified.
    boolean
    Causes a lazily queued task to become queued or executed
    boolean
    Attempts to raise the priority to the priority level specified.
    boolean
    raiseSubOrder(long subOrder)
    Attempts to raise the suborder to the suborder specified.
    boolean
    Attempts to set this task's priority level to the level specified.
    boolean
    setPrioritySubOrderStream(Priority priority, long subOrder, long stream)
    Sets the priority, suborder id, and stream id associated with this task.
    boolean
    setStream(long stream)
    Sets the stream id associated with this task.
    boolean
    setSubOrder(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:
      true If the task was queued, false if 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:
      true If the task has been queued, false if the task has not been queued or is marked as completing.
    • cancel

      boolean cancel()
      Forces this task to be marked as completed.
      Specified by:
      cancel in interface Cancellable
      Returns:
      true if the task was cancelled, false if 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:
      true if this task was executed, false if it was already marked as completed.
    • getPriority

      Priority getPriority()
      Returns the current priority. Note that Priority.COMPLETING will be returned if this task is completing or has completed.
    • setPriority

      boolean setPriority(Priority priority)
      Attempts to set this task's priority level to the level specified.
      Parameters:
      priority - Specified priority level.
      Returns:
      true if successful, false if 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

      boolean raisePriority(Priority priority)
      Attempts to raise the priority to the priority level specified.
      Parameters:
      priority - Priority specified
      Returns:
      false if the current task is completing, true if 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

      boolean lowerPriority(Priority priority)
      Attempts to lower the priority to the priority level specified.
      Parameters:
      priority - Priority specified
      Returns:
      false if the current task is completing, true if 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, or 0 if completing.
      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:
      true if successful, false if 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 suborder.
    • raiseSubOrder

      boolean raiseSubOrder(long subOrder)
      Attempts to raise the suborder to the suborder specified.
      Parameters:
      subOrder - Specified new sub order.
      Returns:
      false if the current task is completing, true if 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:
      false if the current task is completing, true if the suborder was lowered to the specified suborder or was already at the specified suborder or lower.
    • getStream

      long getStream()
      Returns the stream id associated with this task, or 0 if completing.
      Returns:
      The stream id associated with this task.
    • setStream

      boolean setStream(long stream)
      Sets the stream id associated with this task. Ths function has no effect when this task is completing or is completed.
      Parameters:
      stream - Specified new stream.
      Returns:
      true if successful, false if this task is completing or has completed or the queue this task was scheduled on was shutdown, or if the current stream is the same as the new stream.
    • setPrioritySubOrderStream

      boolean setPrioritySubOrderStream(Priority priority, long subOrder, long stream)
      Sets the priority, suborder id, and stream id associated with this task. Ths function has no effect when this task is completing or is completed.
      Parameters:
      priority - Specified new priority.
      subOrder - Specified new sub order.
      stream - Specified new stream.
      Returns:
      true if successful, false if this task is completing or has completed or the queue this task was scheduled on was shutdown, or if the current priority. suborder, and stream are the same as the parameters.
    • getPriorityState

      Atomically retrieves the priority, suborder, and stream for this task. Returns null if the task is completing or cancelled.
      Returns:
      The current priority state, or null if completing or cancelled.