public class UpdatablePriorityBlockingQueue<T> extends ForwardingBlockingQueue<Runnable>
PriorityBlockingQueue that allows to update
the order based on a priority or via the provided methods.
#update(Function function) : Updates the priorities by applying the given function sequentially to the different priorities. The function has update the PrioritizableRunnable by reference. This function is threadsafe#swap(PrioritizableRunnable runnable) allows to swap two elements in the queue| Constructor and Description |
|---|
UpdatablePriorityBlockingQueue()
Creates a new UpdatablePriorityBlockingQueue, it has infiniteinfiniteinfiniteinfiniteinfinite
capacity.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(Runnable element)
See
java.util.concurrent.BlockingQueue#add(), This method may block if the queue
is being updated. |
Collection<PrioritizableRunnable<T>> |
asCollection()
Returns the runnables as an immutable
Collection without maintaining the order given by the priority |
Collection<PrioritizableRunnable<T>> |
asOrderedCollection()
Returns the runnables as an immutable
Collection maintaining the order given by the priority |
protected BlockingQueue<Runnable> |
delegate()
Returns this forwarding class delegate
|
boolean |
offer(Runnable o)
See
java.util.concurrent.BlockingQueue#offer(), This method may block if the queue
is being updated. |
void |
swap(PrioritizableRunnable<T> runnable1,
PrioritizableRunnable<T> runnable2)
Swap the priorities of both PrioritizableRunnable objects to change the
order in the queue
|
Runnable |
take()
See
BlockingQueue.take(), it also waits for any updating
operations to finish. |
protected Optional<org.daisy.common.priority.SwappingPriority<T>> |
tryFind(PrioritizableRunnable<T> runnable)
Tries to find the runnable among the elements in the queue.
|
void |
update(Function<PrioritizableRunnable<T>,Void> function)
Applies the function to all the elements in the queue.
|
drainTo, drainTo, offer, poll, put, remainingCapacity
element, peek, poll, remove, standardOffer, standardPeek, standardPoll
addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, standardAddAll, standardClear, standardContains, standardContainsAll, standardIsEmpty, standardRemove, standardRemoveAll, standardRetainAll, standardToArray, standardToArray, standardToString, toArray, toArray
toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
contains, remove
addAll, clear, containsAll, equals, hashCode, isEmpty, iterator, parallelStream, removeAll, removeIf, retainAll, size, spliterator, stream, toArray, toArray
public UpdatablePriorityBlockingQueue()
protected Optional<org.daisy.common.priority.SwappingPriority<T>> tryFind(PrioritizableRunnable<T> runnable)
public void swap(PrioritizableRunnable<T> runnable1, PrioritizableRunnable<T> runnable2)
public void update(Function<PrioritizableRunnable<T>,Void> function)
function - public Collection<PrioritizableRunnable<T>> asOrderedCollection()
Collection maintaining the order given by the prioritypublic Collection<PrioritizableRunnable<T>> asCollection()
Collection without maintaining the order given by the priorityprotected BlockingQueue<Runnable> delegate()
delegate in class ForwardingBlockingQueue<Runnable>
public boolean offer(Runnable o)
java.util.concurrent.BlockingQueue#offer(), This method may block if the queue
is being updated.offer in interface BlockingQueue<Runnable>
offer in interface Queue<Runnable>
offer in class ForwardingQueue<Runnable>
public boolean add(Runnable element)
java.util.concurrent.BlockingQueue#add(), This method may block if the queue
is being updated.add in interface Collection<Runnable>
add in interface BlockingQueue<Runnable>
add in interface Queue<Runnable>
add in class ForwardingCollection<Runnable>
public Runnable take() throws InterruptedException
BlockingQueue.take(), it also waits for any updating
operations to finish.take in interface BlockingQueue<Runnable>
take in class ForwardingBlockingQueue<Runnable>
InterruptedExceptionCopyright © 2010–2025 The DAISY Consortium. All rights reserved.