fix bug in ScheduledRunnableQueue
@@ -34,13 +34,15 @@ final class ScheduledRunnableQueue {
}
long timestamp = sr.getTimestamp();
- if (timestamp == cachedFirst.getTimestamp()) {
+
+ if (timestamp < cachedFirst.getTimestamp()) {
+ timestampToBucket.put(cachedFirst.getTimestamp(), cachedFirst);
+ cachedFirst = sr;
+ } else if (timestamp == cachedFirst.getTimestamp()) {
cachedFirst.prev = sr;
sr.next = cachedFirst;
cachedFirst = sr;
- return;
- }
-
+ } else {
ScheduledRunnable firstInProperBucket = timestampToBucket.get(timestamp);
if (firstInProperBucket == null) {
timestampToBucket.put(timestamp, sr);
@@ -52,6 +54,7 @@ final class ScheduledRunnableQueue {
timestampToBucket.put(timestamp, sr);
}
}
+ }
public ScheduledRunnable peek() {
return cachedFirst;
