use of org.wildfly.clustering.infinispan.spi.DefaultNonBlockingThreadFactory in project wildfly by wildfly.
the class ClientThreadPoolServiceConfigurator method configure.
@Override
public ServiceConfigurator configure(OperationContext context, ModelNode model) throws OperationFailedException {
int maxThreads = this.definition.getMaxThreads().resolveModelAttribute(context, model).asInt();
int minThreads = this.definition.getMinThreads().resolveModelAttribute(context, model).asInt();
int queueLength = this.definition.getQueueLength().resolveModelAttribute(context, model).asInt();
long keepAliveTime = this.definition.getKeepAliveTime().resolveModelAttribute(context, model).asLong();
boolean nonBlocking = this.definition.isNonBlocking();
this.factory = new ExecutorFactory() {
@Override
public ExecutorService getExecutor(Properties property) {
BlockingQueue<Runnable> queue = queueLength == 0 ? new SynchronousQueue<>() : new LinkedBlockingQueue<>(queueLength);
ThreadFactory factory = new DefaultThreadFactory(new DaemonThreadFactory(DefaultAsyncExecutorFactory.THREAD_NAME));
if (nonBlocking) {
factory = new DefaultNonBlockingThreadFactory(factory);
}
RejectedExecutionHandler handler = nonBlocking ? NonBlockingRejectedExecutionHandler.getInstance() : BlockingRejectedExecutionHandler.getInstance();
return new ThreadPoolExecutor(minThreads, maxThreads, keepAliveTime, TimeUnit.MILLISECONDS, queue, factory, handler);
}
};
return this;
}
Aggregations