Class WeightedQueue<T>

java.lang.Object
org.apache.cassandra.utils.concurrent.WeightedQueue<T>
All Implemented Interfaces:
Iterable<T>, Collection<T>, BlockingQueue<T>, Queue<T>

public class WeightedQueue<T> extends Object implements BlockingQueue<T>
Weighted queue is a wrapper around any blocking queue that turns it into a blocking weighted queue. The queue will weigh each element being added and removed. Adding to the queue is blocked if adding would violate the weight bound. If an element weighs in at larger than the capacity of the queue then exactly one such element will be allowed into the queue at a time. If the weight of an object changes after it is added you are going to have a bad time. Checking weight should be cheap so memoize expensive to compute weights. If weight throws that can also result in leaked permits so it's always a good idea to memoize weight so it doesn't throw. In the interests of not writing unit tests for methods no one uses there is a lot of UnsupportedOperationException. If you need them then add them and add proper unit tests to WeightedQueueTest. "Good" tests. 100% coverage including exception paths and resource leaks.