Created
September 15, 2017 21:30
-
-
Save lwahlmeier/cdd1b0d03607eda348e894893d3581c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public TaskWrapper getNextTask() { | |
// First compare between high and low priority task queues | |
// then depending on that state, we may check starvable | |
TaskWrapper nextTask = null; | |
if (lowPriorityQueueSet.isEmpty() && !highPriorityQueueSet.isEmpty()) { | |
nextTask = highPriorityQueueSet.getNextTask(); | |
} else if (!lowPriorityQueueSet.isEmpty() && !highPriorityQueueSet.isEmpty()) { | |
if(highPriorityQueueSet.timeSinceLastPull() > maxWaitForLowPriorityInMs) { | |
nextTask = lowPriorityQueueSet.getNextTask(); | |
} else { | |
nextTask = highPriorityQueueSet.getNextTask(); | |
} | |
} else if (!lowPriorityQueueSet.isEmpty() && highPriorityQueueSet.isEmpty()) { | |
nextTask = lowPriorityQueueSet.getNextTask(); | |
} else { | |
nextTask = starvablePriorityQueueSet.getNextTask(); | |
} | |
return nextTask; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment