Interface ProcedureScheduler

All Known Implementing Classes:
AbstractProcedureScheduler, SimpleProcedureScheduler

public interface ProcedureScheduler
Keep track of the runnable procedures
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Inserts the specified element at the end of this queue.
    void
    addBack(Procedure proc, boolean notify)
    Inserts the specified element at the end of this queue.
    void
    Inserts the specified element at the front of this queue.
    void
    addFront(Procedure proc, boolean notify)
    Inserts the specified element at the front of this queue.
    void
    Clear current state of scheduler such that it is equivalent to newly created scheduler.
    boolean
     
    Fetch one Procedure from the queue
    poll(long timeout, TimeUnit unit)
    Fetch one Procedure from the queue
    void
    In case the class is blocking on poll() waiting for items to be added, this method should awake poll() and poll() should return.
    int
    Returns the number of elements in this queue.
    void
    Start the scheduler
    void
    Stop the scheduler
    void
    The procedure can't run at the moment.
  • Method Details

    • start

      void start()
      Start the scheduler
    • stop

      void stop()
      Stop the scheduler
    • signalAll

      void signalAll()
      In case the class is blocking on poll() waiting for items to be added, this method should awake poll() and poll() should return.
    • addFront

      void addFront(Procedure proc)
      Inserts the specified element at the front of this queue.
      Parameters:
      proc - the Procedure to add
    • addFront

      void addFront(Procedure proc, boolean notify)
      Inserts the specified element at the front of this queue.
      Parameters:
      proc - the Procedure to add
      notify - whether need to notify worker
    • addBack

      void addBack(Procedure proc)
      Inserts the specified element at the end of this queue.
      Parameters:
      proc - the Procedure to add
    • addBack

      void addBack(Procedure proc, boolean notify)
      Inserts the specified element at the end of this queue.
      Parameters:
      proc - the Procedure to add
      notify - whether need to notify worker
    • yield

      void yield(Procedure proc)
      The procedure can't run at the moment. add it back to the queue, giving priority to someone else.
      Parameters:
      proc - the Procedure to add back to the list
    • hasRunnables

      boolean hasRunnables()
      Returns:
      true if there are procedures available to process, otherwise false.
    • poll

      Procedure poll()
      Fetch one Procedure from the queue
      Returns:
      the Procedure to execute, or null if nothing present.
    • poll

      Procedure poll(long timeout, TimeUnit unit)
      Fetch one Procedure from the queue
      Parameters:
      timeout - how long to wait before giving up, in units of unit
      unit - a TimeUnit determining how to interpret the timeout parameter
      Returns:
      the Procedure to execute, or null if nothing present.
    • size

      int size()
      Returns the number of elements in this queue.
      Returns:
      the number of elements in this queue.
    • clear

      void clear()
      Clear current state of scheduler such that it is equivalent to newly created scheduler. Used for testing failure and recovery.