Class ImageLoadQueue

java.lang.Object
org.xhtmlrenderer.swing.ImageLoadQueue

class ImageLoadQueue extends Object
A thread-safe queue containing BackgroundImageLoaderItem, each of which represents one image (identified by a URI) which needs to be loaded.
  • Field Details

  • Constructor Details

    • ImageLoadQueue

      ImageLoadQueue()
  • Method Details

    • addToQueue

      public void addToQueue(ImageResourceLoader imageResourceLoader, String uri, MutableFSImage mfsi, int width, int height)
      Queues a new item to be loaded. Thread-safe.
      Parameters:
      uri - URI of the item to be loaded. As there is no good way of reporting failures, you should ensure the URI is a proper URL before calling this method.
    • getTask

      public ImageLoadItem getTask() throws InterruptedException
      Returns the next available task from the queue, or blocks if there are no more; items are returned in FIFO order. If none are available, the method will block until the next items is pushed into the queue.
      Returns:
      an ImageLoadItem
      Throws:
      InterruptedException - if the wait (block) was interrupted externally
    • reset

      public void reset()
      Removes all items currently in the queue.
    • kill

      public void kill()
      Indicates that no more items will be added to the queue, no more items currently in the queue will be loaded, and that worker threads polling this queue should shut down.
    • isKillSwitch

      public static boolean isKillSwitch(Object queueItem)
      Returns true if the item, retrieved from the queue via getTask(), is a kill switch, meaning the worker that retrieved it should stop polling.
      Parameters:
      queueItem - an item retrieved from the queue.
      Returns:
      true if the item, retrieved from the queue via getTask(), is a kill switch, meaning the worker that retrieved it should stop polling.
    • size

      public int size()