E - type of elements held in this queue, extending PQEntrypublic class PriBlockingQueue<E extends PQEntry> extends PriorityBlockingQueue<E>
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 with comprehensive statistics tracking and performance monitoring.
| Modifier and Type | Field and Description |
|---|---|
protected I2PAppContext |
_context |
protected Log |
_log |
protected String |
_name |
protected static int |
DEFAULT_BACKLOG_SIZE
Default backlog and max size depending on system speed.
|
protected static int |
DEFAULT_MAX_SIZE |
static String |
PROP_BACKLOG_SIZE |
static String |
PROP_MAX_SIZE
Configuration property keys for max size and backlog thresholds.
|
protected static long[] |
RATES
Time windows for rate statistics in milliseconds.
|
| Constructor and Description |
|---|
PriBlockingQueue(I2PAppContext ctx,
String name,
int initialCapacity)
Constructs a new priority blocking queue with the given initial capacity.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
isBacklogged()
Checks if the queue size is above the backlog threshold, indicating
potential congestion or overload.
|
boolean |
offer(E o)
Inserts the specified element into this queue if it is not full,
applying sequence timestamp to ensure FIFO ordering within priority.
|
protected void |
timestamp(E o)
Assigns a unique sequence number to the element to maintain FIFO ordering
among elements of the same priority.
|
add, clear, comparator, contains, drainTo, drainTo, iterator, offer, peek, poll, poll, put, remainingCapacity, remove, size, spliterator, take, toArray, toArray, toStringaddAll, element, removecontainsAll, isEmpty, removeAll, retainAllclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddAll, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, streamprotected final transient I2PAppContext _context
protected final transient Log _log
protected final String _name
protected static final int DEFAULT_BACKLOG_SIZE
protected static final int DEFAULT_MAX_SIZE
public static final String PROP_BACKLOG_SIZE
public static final String PROP_MAX_SIZE
protected static final long[] RATES
public PriBlockingQueue(I2PAppContext ctx, String name, int initialCapacity)
ctx - the I2P application contextname - a name for this queue instance (used in stats)initialCapacity - the initial capacity for the priority queuepublic boolean isBacklogged()
public boolean offer(E o)
protected void timestamp(E o)
o - the element to timestamp