use of org.infinispan.commons.executors.NonBlockingResource in project infinispan by infinispan.
the class EnhancedQueueExecutorFactory method createExecutor.
@Override
public ManageableThreadPoolExecutorService createExecutor(ThreadFactory factory) {
if (factory instanceof NonBlockingResource) {
throw new IllegalStateException("Executor factory configured to be blocking and received a thread" + " factory that creates non-blocking threads!");
}
EnhancedQueueExecutor.Builder builder = new EnhancedQueueExecutor.Builder();
builder.setThreadFactory(factory);
builder.setCorePoolSize(coreThreads);
builder.setMaximumPoolSize(maxThreads);
builder.setGrowthResistance(0.0f);
builder.setMaximumQueueSize(queueLength);
builder.setKeepAliveTime(keepAlive, TimeUnit.MILLISECONDS);
EnhancedQueueExecutor enhancedQueueExecutor = builder.build();
enhancedQueueExecutor.setHandoffExecutor(task -> BlockingRejectedExecutionHandler.getInstance().rejectedExecution(task, enhancedQueueExecutor));
return enhancedQueueExecutor;
}
Aggregations