Class PriorityRunnable

java.lang.Object
org.axonframework.axonserver.connector.PriorityRunnable
All Implemented Interfaces:
Comparable<PriorityTask>, Runnable, PriorityTask

public class PriorityRunnable extends Object implements Runnable, PriorityTask
A wrapper class of Runnables that adheres to a priority by implementing PriorityTask. Uses a combination of priority and index to compare between this and other priority task instances. A calculator (e.g. CommandPriorityCalculator) defines the priority of the task. This task uses the index to differentiate between tasks with the same priority, ensuring the insert order is leading in those scenarios.
Since:
4.6.0
Author:
Stefan Dragisic, Milan Savic, Allard Buijze, Steven van Beelen
See Also:
  • Constructor Details

    • PriorityRunnable

      public PriorityRunnable(Runnable task, long priority, long sequence)
      Construct a priority task.
      Parameters:
      task - The Runnable that should be executed with a priority.
      priority - The priority of the task to execute, dedicating the order among tasks.
      sequence - The sequence of the task to execute, dedicating the order among equal priority tasks.
  • Method Details

    • run

      public void run()
      Specified by:
      run in interface Runnable
    • priority

      public long priority()
      Description copied from interface: PriorityTask
      Returns the priority of this task.
      Specified by:
      priority in interface PriorityTask
      Returns:
      The priority of this task.
    • sequence

      public long sequence()
      Description copied from interface: PriorityTask
      Returns the sequence of this task.
      Specified by:
      sequence in interface PriorityTask
      Returns:
      The sequence of this task.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object