Class ActionQueue

java.lang.Object
com.renomad.minum.queue.ActionQueue
All Implemented Interfaces:
AbstractActionQueue

public final class ActionQueue extends Object implements 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.

Example:

This example shows where an InputStream representing the bytes of an image file are sent to the ActionQueue for processing. The call to enqueue(String, ThrowingRunnable) returns immediately, and processing continues on another thread.

 
  ActionQueue photoResizingQueue;
  InputStream photoInputStream;
  photoResizingQueue = new ActionQueue("photo_resizing", context).initialize();
  photoResizingQueue.enqueue("resize an image", () -> resizeImage(photoInputStream));
 
 
  • Constructor Details

    • ActionQueue

      public ActionQueue(String name, Context context)
      See the ActionQueue description for more detail. This constructor will build your new action queue and handle registering it with a list of other action queues in the Context object.
      Parameters:
      name - give this object a unique, explanatory name.
  • Method Details