I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 5eff26e4 authored by zzz's avatar zzz
Browse files

add minimum priority check

parent 4e785176
No related branches found
No related tags found
No related merge requests found
...@@ -67,7 +67,8 @@ public class CoDelPriorityBlockingQueue<E extends CDPQEntry> extends PriorityBlo ...@@ -67,7 +67,8 @@ public class CoDelPriorityBlockingQueue<E extends CDPQEntry> extends PriorityBlo
private final String STAT_DROP; private final String STAT_DROP;
private final String STAT_DELAY; private final String STAT_DELAY;
private static final long[] RATES = {5*60*1000}; private static final long[] RATES = {5*60*1000};
private static final int[] PRIORITIES = {100, 200, 300, 400, 500}; public static final int MIN_PRIORITY = 100;
private static final int[] PRIORITIES = {MIN_PRIORITY, 200, 300, 400, 500};
/** if priority is >= this, never drop */ /** if priority is >= this, never drop */
public static final int DONT_DROP_PRIORITY = 1000; public static final int DONT_DROP_PRIORITY = 1000;
...@@ -89,29 +90,25 @@ public class CoDelPriorityBlockingQueue<E extends CDPQEntry> extends PriorityBlo ...@@ -89,29 +90,25 @@ public class CoDelPriorityBlockingQueue<E extends CDPQEntry> extends PriorityBlo
@Override @Override
public boolean add(E o) { public boolean add(E o) {
o.setSeqNum(_seqNum.incrementAndGet()); timestamp(o);
o.setEnqueueTime(_context.clock().now());
return super.add(o); return super.add(o);
} }
@Override @Override
public boolean offer(E o) { public boolean offer(E o) {
o.setSeqNum(_seqNum.incrementAndGet()); timestamp(o);
o.setEnqueueTime(_context.clock().now());
return super.offer(o); return super.offer(o);
} }
@Override @Override
public boolean offer(E o, long timeout, TimeUnit unit) { public boolean offer(E o, long timeout, TimeUnit unit) {
o.setSeqNum(_seqNum.incrementAndGet()); timestamp(o);
o.setEnqueueTime(_context.clock().now());
return super.offer(o, timeout, unit); return super.offer(o, timeout, unit);
} }
@Override @Override
public void put(E o) { public void put(E o) {
o.setSeqNum(_seqNum.incrementAndGet()); timestamp(o);
o.setEnqueueTime(_context.clock().now());
super.put(o); super.put(o);
} }
...@@ -164,6 +161,14 @@ public class CoDelPriorityBlockingQueue<E extends CDPQEntry> extends PriorityBlo ...@@ -164,6 +161,14 @@ public class CoDelPriorityBlockingQueue<E extends CDPQEntry> extends PriorityBlo
/////// private below here /////// private below here
private void timestamp(E o) {
o.setSeqNum(_seqNum.incrementAndGet());
o.setEnqueueTime(_context.clock().now());
if (o.getPriority() < MIN_PRIORITY && _log.shouldLog(Log.WARN))
_log.warn(_name + " added item with low priority " + o.getPriority() +
": " + o);
}
/** /**
* Caller must synch on this * Caller must synch on this
* @param entry may be null * @param entry may be null
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment