/** * Constructs a new thread pool, though no threads will be started till it accepts it's first * request. This provides the extra parameters to tune what tasks submitted without a priority * will be scheduled as. As well as the maximum wait for low priority tasks. The longer low * priority tasks wait for a worker, the less chance they will have to create a thread. But it * also makes low priority tasks execution time less predictable. * * @param poolSize Thread pool size that should be maintained * @param defaultPriority priority to give tasks which do not specify it * @param maxWaitForLowPriorityInMs time low priority tasks wait for a worker * @param threadFactory thread factory for producing new threads within executor * @param maxStatisticWindowSize maximum number of samples to keep internally * @param accurateTime {@code true} to ensure that delays and durations are not under reported */ public PrioritySchedulerStatisticTracker(int poolSize, TaskPriority defaultPriority, long maxWaitForLowPriorityInMs, ThreadFactory threadFactory, int maxStatisticWindowSize, boolean accurateTime) { super(new StatisticWorkerPool(threadFactory, poolSize, new PriorityStatisticManager(maxStatisticWindowSize, accurateTime)), defaultPriority, maxWaitForLowPriorityInMs); this.statsManager = ((StatisticWorkerPool)workerPool).statsManager; }
@Before @Override public void setup() { workerPool = localWorkerPool = new StatisticWorkerPool(new ConfigurableThreadFactory(), 1, new PriorityStatisticManager(100, false)); qm = new VisibilityPriorityScheduler.VisibilityQueueManager(workerPool, 1000); // set the queue manager, but then make sure we kill the worker localWorkerPool.start(qm); }
/** * Constructs a new thread pool, though no threads will be started till it accepts it's first * request. This provides the extra parameters to tune what tasks submitted without a priority * will be scheduled as. As well as the maximum wait for low priority tasks. The longer low * priority tasks wait for a worker, the less chance they will have to create a thread. But it * also makes low priority tasks execution time less predictable. * * @param poolSize Thread pool size that should be maintained * @param defaultPriority priority to give tasks which do not specify it * @param maxWaitForLowPriorityInMs time low priority tasks wait for a worker * @param threadFactory thread factory for producing new threads within executor * @param maxStatisticWindowSize maximum number of samples to keep internally * @param accurateTime {@code true} to ensure that delays and durations are not under reported */ public PrioritySchedulerStatisticTracker(int poolSize, TaskPriority defaultPriority, long maxWaitForLowPriorityInMs, ThreadFactory threadFactory, int maxStatisticWindowSize, boolean accurateTime) { super(new StatisticWorkerPool(threadFactory, poolSize, new PriorityStatisticManager(maxStatisticWindowSize, accurateTime)), defaultPriority, maxWaitForLowPriorityInMs); this.statsManager = ((StatisticWorkerPool)workerPool).statsManager; }