/** * Thread pool well suited for running CPU intensive computations on the tasks thread. * * @param threadName Name to prefix to thread while tasks on this pool execute, or {@code null} * @return Pool for CPU bound tasks */ public static SchedulerService computationPool(String threadName) { if (StringUtils.isNullOrEmpty(threadName)) { return COMPUTATION_POOL; } else { return new ThreadRenamingSchedulerService(COMPUTATION_POOL, threadName, false); } }
/** * Thread pool well suited for running CPU intensive computations on the tasks thread. * * @param threadName Name to prefix to thread while tasks on this pool execute, or {@code null} * @return Pool for CPU bound tasks */ public static SchedulerService computationPool(String threadName) { if (StringUtils.isNullOrEmpty(threadName)) { return COMPUTATION_POOL; } else { return new ThreadRenamingSchedulerService(COMPUTATION_POOL, threadName, false); } }
@Override protected SchedulerServiceLimiter makeLimiter(String limiterThreadName) { return new SchedulerServiceLimiter(StringUtils.isNullOrEmpty(limiterThreadName) ? scheduler : new ThreadRenamingSchedulerService(scheduler, limiterThreadName, false), getMaxConcurrencyPerKey(), limitFutureListenersExecution); }
/** * Low priority pool for scheduling cleanup or otherwise tasks which could be significantly * delayed. If not single threaded this pool will execute only on any general processing threads * which are available. By default there is only one, but it can be increased by invoking * {@link #increaseGenericThreads(int)}. * * @deprecated use {@link #lowPrioritySingleThreadPool(String)} or {@link #lowPriorityPool(String)} * * @param singleThreaded {@code true} indicates that being blocked by other low priority tasks is not a concern * @param threadName Name to prefix to thread while tasks on this pool execute, or {@code null} * @return Pool for running or scheduling out low priority tasks */ @Deprecated public static SchedulerService lowPriorityPool(boolean singleThreaded, String threadName) { SchedulerService scheduler = singleThreaded ? SINGLE_THREADED_LOW_PRIORITY_POOL : LOW_PRIORITY_POOL; if (StringUtils.isNullOrEmpty(threadName)) { return scheduler; } else { return new ThreadRenamingSchedulerService(scheduler, threadName, false); } }
/** * Low priority pool for scheduling cleanup or otherwise tasks which could be significantly * delayed. This pool will execute only on any general processing threads which are available. * By default there is only one, but it can be increased by invoking * {@link #increaseGenericThreads(int)}. * * @param threadName Name to prefix to thread while tasks on this pool execute, or {@code null} * @return Pool for running or scheduling out low priority tasks */ public static SchedulerService lowPriorityPool(String threadName) { if (StringUtils.isNullOrEmpty(threadName)) { return LOW_PRIORITY_POOL; } else { return new ThreadRenamingSchedulerService(LOW_PRIORITY_POOL, threadName, false); } }
/** * Low priority pool for scheduling cleanup or otherwise tasks which could be significantly * delayed. This pool will execute only on any general processing threads which are available. * By default there is only one, but it can be increased by invoking * {@link #increaseGenericThreads(int)}. * * @param threadName Name to prefix to thread while tasks on this pool execute, or {@code null} * @return Pool for running or scheduling out low priority tasks */ public static SchedulerService lowPriorityPool(String threadName) { if (StringUtils.isNullOrEmpty(threadName)) { return LOW_PRIORITY_POOL; } else { return new ThreadRenamingSchedulerService(LOW_PRIORITY_POOL, threadName, false); } }
@Override protected SchedulerServiceLimiter makeLimiter(String limiterThreadName) { return new SchedulerServiceLimiter(StringUtils.isNullOrEmpty(limiterThreadName) ? scheduler : new ThreadRenamingSchedulerService(scheduler, limiterThreadName, false), getMaxConcurrencyPerKey(), limitFutureListenersExecution); }
/** * Low priority pool for scheduling cleanup or otherwise tasks which could be significantly * delayed. If not single threaded this pool will execute only on any general processing threads * which are available. By default there is only one, but it can be increased by invoking * {@link #increaseGenericThreads(int)}. * * @deprecated use {@link #lowPrioritySingleThreadPool(String)} or {@link #lowPriorityPool(String)} * * @param singleThreaded {@code true} indicates that being blocked by other low priority tasks is not a concern * @param threadName Name to prefix to thread while tasks on this pool execute, or {@code null} * @return Pool for running or scheduling out low priority tasks */ @Deprecated public static SchedulerService lowPriorityPool(boolean singleThreaded, String threadName) { SchedulerService scheduler = singleThreaded ? SINGLE_THREADED_LOW_PRIORITY_POOL : LOW_PRIORITY_POOL; if (StringUtils.isNullOrEmpty(threadName)) { return scheduler; } else { return new ThreadRenamingSchedulerService(scheduler, threadName, false); } }
/** * This returns a thread pool which is designed for an "isolated" task. An isolated task is one * where there is not other scheduling needs in this area of code. This is equivalent to * invoking {@link #singleThreadPool()} for every task submitted. However that implementation is * better if you have a multiple tasks you need to execute, and this one is much better if you * have a single task to execute / schedule. * <p> * Implementation wise every task submitted on the returned pool will increase the pool size * (if necessary) to allow execution, and then decrease the size once execution completes. * Because of this, {@link #singleThreadPool()} is much better if you can reuse the pool (to * reduce size churn), and this is much better if you only have a single task (to reduce memory * overhead). * * @param threadName Name to prefix to thread while tasks on this pool execute, or {@code null} * @return Pool which will ensure there is a thread available for every task executed on it */ public static SchedulerService isolatedTaskPool(String threadName) { if (StringUtils.isNullOrEmpty(threadName)) { return PER_TASK_SIZING_POOL; } else { return new ThreadRenamingSchedulerService(PER_TASK_SIZING_POOL, threadName, false); } }
/** * This returns a thread pool which is designed for an "isolated" task. An isolated task is one * where there is not other scheduling needs in this area of code. This is equivalent to * invoking {@link #singleThreadPool()} for every task submitted. However that implementation is * better if you have a multiple tasks you need to execute, and this one is much better if you * have a single task to execute / schedule. * <p> * Implementation wise every task submitted on the returned pool will increase the pool size * (if necessary) to allow execution, and then decrease the size once execution completes. * Because of this, {@link #singleThreadPool()} is much better if you can reuse the pool (to * reduce size churn), and this is much better if you only have a single task (to reduce memory * overhead). * * @param threadName Name to prefix to thread while tasks on this pool execute, or {@code null} * @return Pool which will ensure there is a thread available for every task executed on it */ public static SchedulerService isolatedTaskPool(String threadName) { if (StringUtils.isNullOrEmpty(threadName)) { return PER_TASK_SIZING_POOL; } else { return new ThreadRenamingSchedulerService(PER_TASK_SIZING_POOL, threadName, false); } }
@Override public SchedulerService makeSchedulerService(int poolSize, boolean prestartIfAvailable) { SchedulerService scheduler = schedulerFactory.makeSchedulerService(poolSize, prestartIfAvailable); return new ThreadRenamingSchedulerService(scheduler, THREAD_NAME, false); }