public final class PrioritySendPool extends Object
Client messages (PRIORITY_MY_DATA=1000) are always dequeued before transit messages (PRIORITY_PARTICIPATING=200). When the pool is full and a higher-priority message arrives, the lowest-priority message is evicted. Non-blocking: never stalls the caller.
Sorted array with binary search insertion — optimal for the small bounded sizes (64–8192) used by the NTCP send path. Synchronized on the backing list; contention is minimal because the thread that offers almost always polls immediately (handoff pattern).
| Constructor and Description |
|---|
PrioritySendPool(int capacity)PrioritySendPool. |
| Modifier and Type | Method and Description |
|---|---|
void | drainTo(ArrayList<OutNetMessage> target)Drain all messages into the target list (for resize). |
int | getAddedCount()Snapshot of added/evicted/dropped counters since construction. |
int | getCapacity() |
int | getDroppedCount() |
int | getEvictedCount() |
boolean | offer(OutNetMessage msg)Non-blocking offer with priority eviction. |
OutNetMessage | poll()Return the highest-priority message, or null if empty. |
int | remainingCapacity()remainingCapacity. |
void | setCapacity(int newCapacity)Resize the pool. |
int | size()size. |
public void drainTo(ArrayList<OutNetMessage> target)
public int getAddedCount()
public int getCapacity()
public int getDroppedCount()
public int getEvictedCount()
public boolean offer(OutNetMessage msg)
If the pool has room, the message is inserted in sorted position
and the method returns true. If the pool is full and the
incoming message has strictly higher priority than the lowest-priority
message in the pool, the lowest is evicted and the new message takes
its place. Otherwise the incoming message is dropped.
msg - the outbound message to enqueuetrue if added, false if droppedpublic OutNetMessage poll()
public int remainingCapacity()
public void setCapacity(int newCapacity)
public int size()