@Override public int getWaitingForExecutionTaskCount() { int result = 0; for (TaskPriority p : TaskPriority.values()) { result += getWaitingForExecutionTaskCount(p); } return result; }
@Override public int getWaitingForExecutionTaskCount() { int result = 0; for (TaskPriority p : TaskPriority.values()) { result += getWaitingForExecutionTaskCount(p); } return result; }
public long getTotalExecutionCount() { long result = 0; for (TaskPriority p : TaskPriority.values()) { result += getExecutionCount(p).sum(); } return result; }
public long getTotalExecutionCount() { long result = 0; for (TaskPriority p : TaskPriority.values()) { result += getExecutionCount(p).sum(); } return result; }
/** * Checks if there are tasks ready to be run on the scheduler. Generally this is called from * the same thread that would call {@link #tick(ExceptionHandler)} (but does not have to be). * If {@link #tick(ExceptionHandler)} is not currently being called, this call indicates if the * next {@link #tick(ExceptionHandler)} will have at least one task to run. If * {@link #tick(ExceptionHandler)} is currently being invoked, this call will do a best attempt * to indicate if there is at least one more task to run (not including the task which may * currently be running). It's a best attempt as it will try not to block the thread invoking * {@link #tick(ExceptionHandler)} to prevent it from accepting additional work. * * @return {@code true} if there are task waiting to run */ public boolean hasTaskReadyToRun() { for (TaskPriority p : TaskPriority.values()) { if (hasTaskReadyToRun(queueManager.getQueueSet(p))) { return true; } } return false; }
/** * Checks if there are tasks ready to be run on the scheduler. Generally this is called from * the same thread that would call {@link #tick(ExceptionHandler)} (but does not have to be). * If {@link #tick(ExceptionHandler)} is not currently being called, this call indicates if the * next {@link #tick(ExceptionHandler)} will have at least one task to run. If * {@link #tick(ExceptionHandler)} is currently being invoked, this call will do a best attempt * to indicate if there is at least one more task to run (not including the task which may * currently be running). It's a best attempt as it will try not to block the thread invoking * {@link #tick(ExceptionHandler)} to prevent it from accepting additional work. * * @return {@code true} if there are task waiting to run */ public boolean hasTaskReadyToRun() { for (TaskPriority p : TaskPriority.values()) { if (hasTaskReadyToRun(queueManager.getQueueSet(p))) { return true; } } return false; }
@Override public int getQueuedTaskCount() { int result = 0; for (TaskPriority p : TaskPriority.values()) { result += getQueueManager().getQueueSet(p).queueSize(); } return result; }
@Override public int getQueuedTaskCount() { int result = 0; for (TaskPriority p : TaskPriority.values()) { result += getQueueManager().getQueueSet(p).queueSize(); } return result; }
public void resetCollectedStats() { for (TaskPriority p : TaskPriority.values()) { getExecutionDelaySamplesInternal(p).clear(); getExecutionDurationSamplesInternal(p).clear(); } }
public void resetCollectedStats() { for (TaskPriority p : TaskPriority.values()) { getExecutionDelaySamplesInternal(p).clear(); getExecutionDurationSamplesInternal(p).clear(); } }
public static void resetCollectedStatsTest(StatisticPriorityScheduler scheduler) { TestRunnable lastRunnable = null; boolean flip = false; for (int i = 0; i < TEST_QTY; i++) { lastRunnable = new TestRunnable(); if (flip) { scheduler.execute(lastRunnable, TaskPriority.High); flip = false; } else { scheduler.execute(lastRunnable, TaskPriority.Low); flip = true; } } lastRunnable.blockTillFinished(); // block till all are finished blockTillSchedulerIdle(scheduler, TEST_QTY); // reset stats scheduler.resetCollectedStats(); assertEquals(-1, scheduler.getAverageExecutionDuration(), 0); for (TaskPriority p : TaskPriority.values()) { assertEquals(-1, scheduler.getAverageExecutionDelay(p), 0); } }
@Test public void resetCollectedStatsTest() { NoThreadSchedulerStatisticTracker scheduler = new NoThreadSchedulerStatisticTracker(); TestRunnable lastRunnable = null; boolean flip = false; for (int i = 0; i < TEST_QTY; i++) { lastRunnable = new TestRunnable(1); if (flip) { scheduler.execute(lastRunnable, TaskPriority.High); flip = false; } else { scheduler.execute(lastRunnable, TaskPriority.Low); flip = true; } } scheduler.tick(null); // reset stats scheduler.resetCollectedStats(); assertEquals(-1, scheduler.getAverageExecutionDuration(), 0); for (TaskPriority p : TaskPriority.values()) { assertEquals(-1, scheduler.getAverageExecutionDelay(p), 0); } }