}
}
private long runAllDue() throws InterruptedException {
long nextRunTime = 0;
TimedTask task;
while ((task = scheduledTasks.poll(60, java.util.concurrent.TimeUnit.SECONDS)) != null) {
if (!task.isDue(currentTimeMillis())) {
parkUntil(task.nextRuntime());
}
/**
* Sechedule the task for execution.
*/
if (!queue.offer(task, 5, java.util.concurrent.TimeUnit.SECONDS)) {
saturationPolicy.dealWith(task);
}
if (task.calculateNextRuntime()) {
scheduledTasks.offer(task);
}
}
return nextRunTime;