- Type Parameters:
E- type of elements held in this queue, extendingPQEntry
- All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, BlockingQueue<E>, Queue<E>
- Direct Known Subclasses:
CoDelPriorityBlockingQueue
Extends PriorityBlockingQueue to provide bounded capacity with FIFO ordering for elements sharing the same priority. Entries extend PQEntry to include sequence numbers for insertion ordering.
Applies sequence timestamps on insertion to ensure FIFO behavior within same priority level while maintaining priority-based ordering. Capacity is controlled by configuration properties to prevent unbounded growth and enable backpressure management.
Thread-safe implementation suitable for concurrent producer-consumer scenarios.
- See Also:
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final I2PAppContextThe I2P application context.protected final LogThe log instance.protected final StringThe queue name.protected static final intDefault backlog size threshold, depends on system speed.protected static final intDefault maximum queue size.static final StringProperty key for backlog threshold.static final StringProperty key for maximum queue size.Constructor Summary
ConstructorsConstructorDescriptionPriBlockingQueue(I2PAppContext ctx, String name, int initialCapacity) Priority blocking queue with the given initial capacity.Method Summary
All MethodsModifier and TypeMethodDescriptionbooleanChecks if the queue size is above the backlog threshold, indicating potential congestion or overload.booleanInserts the specified element into this queue if it is not full, applying sequence timestamp to ensure FIFO ordering within priority.protected voidAssigns a unique sequence number to the element to maintain FIFO ordering among elements of the same priority.Methods inherited from class PriorityBlockingQueue
add, clear, comparator, contains, drainTo, drainTo, forEach, iterator, offer, peek, poll, poll, put, remainingCapacity, remove, removeAll, removeIf, retainAll, size, spliterator, take, toArray, toArray, toStringMethods inherited from class AbstractQueue
addAll, element, removeMethods inherited from class AbstractCollection
containsAll, isEmptyMethods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Collection
equals, hashCode, parallelStream, stream, toArray
Field Details
_context
The I2P application context._log
The log instance._name
The queue name.DEFAULT_BACKLOG_SIZE
protected static final int DEFAULT_BACKLOG_SIZEDefault backlog size threshold, depends on system speed.DEFAULT_MAX_SIZE
protected static final int DEFAULT_MAX_SIZEDefault maximum queue size.PROP_MAX_SIZE
Property key for maximum queue size.- See Also:
PROP_BACKLOG_SIZE
Property key for backlog threshold.- See Also:
Constructor Details
PriBlockingQueue
Priority blocking queue with the given initial capacity. The queue is bounded by a configurable max size read once at construction.- Parameters:
ctx- the I2P application contextname- a name for this queue instanceinitialCapacity- the initial capacity for the priority queue
Method Details
offer
Inserts the specified element into this queue if it is not full, applying sequence timestamp to ensure FIFO ordering within priority. Returns false if the queue has reached its maximum size.The capacity check is best-effort: size() and
offer(E)are not atomic, so the queue may briefly exceed _maxSize under concurrent insertions. PriorityBlockingQueue is unbounded, so an exact atomic bound would require external synchronization.isBacklogged
public boolean isBacklogged()Checks if the queue size is above the backlog threshold, indicating potential congestion or overload.- Returns:
- true if queue size is above backlog size threshold, false otherwise
timestamp
Assigns a unique sequence number to the element to maintain FIFO ordering among elements of the same priority.- Parameters:
o- the element to timestamp