use of org.apache.tapestry5.ioc.internal.services.NonParallelExecutor in project tapestry-5 by apache.
the class TapestryIOCModule method buildDeferredExecution.
public static ParallelExecutor buildDeferredExecution(@Symbol(IOCSymbols.THREAD_POOL_CORE_SIZE) int coreSize, @Symbol(IOCSymbols.THREAD_POOL_MAX_SIZE) int maxSize, @Symbol(IOCSymbols.THREAD_POOL_KEEP_ALIVE) @IntermediateType(TimeInterval.class) int keepAliveMillis, @Symbol(IOCSymbols.THREAD_POOL_ENABLED) boolean threadPoolEnabled, @Symbol(IOCSymbols.THREAD_POOL_QUEUE_SIZE) int queueSize, PerthreadManager perthreadManager, RegistryShutdownHub shutdownHub, ThunkCreator thunkCreator) {
if (!threadPoolEnabled)
return new NonParallelExecutor();
LinkedBlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<Runnable>(queueSize);
final ThreadPoolExecutor executorService = new ThreadPoolExecutor(coreSize, maxSize, keepAliveMillis, TimeUnit.MILLISECONDS, workQueue);
shutdownHub.addRegistryShutdownListener(new Runnable() {
@Override
public void run() {
executorService.shutdown();
}
});
return new ParallelExecutorImpl(executorService, thunkCreator, perthreadManager);
}
Aggregations