Search in sources :

Example 1 with NonBlockingResource

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;
}
Also used : EnhancedQueueExecutor(org.jboss.threads.EnhancedQueueExecutor) NonBlockingResource(org.infinispan.commons.executors.NonBlockingResource)

Aggregations

NonBlockingResource (org.infinispan.commons.executors.NonBlockingResource)1 EnhancedQueueExecutor (org.jboss.threads.EnhancedQueueExecutor)1