Package org.xhtmlrenderer.swing
Class ImageLoadQueue
java.lang.Object
org.xhtmlrenderer.swing.ImageLoadQueue
A thread-safe queue containing BackgroundImageLoaderItem, each of which represents one image (identified by a URI)
which needs to be loaded.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final LinkedList<ImageLoadItem>
private static final ImageLoadItem
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addToQueue
(ImageResourceLoader imageResourceLoader, String uri, MutableFSImage mfsi, int width, int height) Queues a new item to be loaded.getTask()
Returns the next available task from the queue, or blocks if there are no more; items are returned in FIFO order.static boolean
isKillSwitch
(Object queueItem) Returns true if the item, retrieved from the queue viagetTask()
, is a kill switch, meaning the worker that retrieved it should stop polling.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.void
reset()
Removes all items currently in the queue.int
size()
-
Field Details
-
KILL_SWITCH
-
_loadQueue
-
-
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
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
Returns true if the item, retrieved from the queue viagetTask()
, 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()
-