Interface AbstractActionQueue

All Known Implementing Classes:
ActionQueue

public interface AbstractActionQueue
This class provides the ability to pop items into a queue thread-safely and know they'll happen later.

For example, this is helpful for minum.logging, or passing functions to a minum.database. It lets us run a bit faster, since the I/O actions are happening on a separate thread and the only time required is passing the function of what we want to run later.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    enqueue(String description, ThrowingRunnable action)
    Adds something to the queue to be processed.
    Get the Queue of data that is supposed to get processed.
    Start the queue's processing
    boolean
    Indicate whether this has had its stop() method completed.
    void
    This will prevent any new actions being queued (by setting the stop flag to true and thus causing an exception to be thrown when a call is made to [enqueue]) and will block until the queue is empty.
    void
    stop(int count, int sleepTime)
    Stops the action queue
  • Method Details

    • initialize

      AbstractActionQueue initialize()
      Start the queue's processing
    • enqueue

      void enqueue(String description, ThrowingRunnable action)
      Adds something to the queue to be processed.

      An example:

         actionQueue.enqueue("Write person file to disk at " + filePath, () -> {
                   Files.writeString(filePath, pf.serialize());
               });
       
    • stop

      void stop(int count, int sleepTime)
      Stops the action queue
      Parameters:
      count - how many loops to wait before we crash it closed
      sleepTime - how long to wait in milliseconds between loops
    • stop

      void stop()
      This will prevent any new actions being queued (by setting the stop flag to true and thus causing an exception to be thrown when a call is made to [enqueue]) and will block until the queue is empty.
    • getQueue

      Get the Queue of data that is supposed to get processed.
    • isStopped

      boolean isStopped()
      Indicate whether this has had its stop() method completed.