Type Parameters:
T - item type
All Known Subinterfaces:
DelayingQueue<T>, RateLimitingQueue<T>
All Known Implementing Classes:
DefaultDelayingQueue, DefaultRateLimitingQueue, DefaultWorkQueue

public interface WorkQueue<T>
The workqueue interface defines the queue behavior.

The code has been copied from the official client and modified: WorkQueue

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(T item)
    Adds an item to the queue of items which need processing.
    void
    done(T item)
    Marks an item as completed.
    get()
    Gets an item for processing.
    boolean
    Returns whether the queue is shutdown.
    int
    Returns the current queue length, for informational purposes only.
    void
    Initiates a shutdown of the work queue.
    void
    Starts the work queue.
  • Method Details

    • add

      void add(@NonNull T item)
      Adds an item to the queue of items which need processing.
      Parameters:
      item - item to add
    • length

      int length()
      Returns the current queue length, for informational purposes only.
      Returns:
      current queue length
    • get

      @Nullable T get() throws InterruptedException
      Gets an item for processing. It blocks until there is an available item.
      Returns:
      the item
      Throws:
      InterruptedException
    • done

      void done(@NonNull T item)
      Marks an item as completed. Also, it will add the same item back to the queue of items which need processing if the item was marked as dirty while processing was in progress.
      Parameters:
      item - specific item
    • start

      void start()
      Starts the work queue. Can be called after shutdown to enable queue usage.
    • shutdown

      void shutdown()
      Initiates a shutdown of the work queue. All added items whose processing not started will be ignored and removed from the queue.
    • isShutdown

      boolean isShutdown()
      Returns whether the queue is shutdown.
      Returns:
      true if the queue is shutdown