@EachProperty(value="micronaut.executors") public class UserExecutorConfiguration extends Object implements ExecutorConfiguration
ExecutorService
instances that are made available as beans.Modifier and Type | Field and Description |
---|---|
static int |
AVAILABLE_PROCESSORS
Number of available processors.
|
protected String |
name |
protected Integer |
nThreads |
PREFIX, PREFIX_CONSUMER, PREFIX_IO, PREFIX_SCHEDULED
Modifier | Constructor and Description |
---|---|
protected |
UserExecutorConfiguration(String name,
Integer nThreads,
ExecutorType type,
Integer parallelism,
Integer corePoolSize,
Class<? extends ThreadFactory> threadFactoryClass)
Default Constructor.
|
public static final int AVAILABLE_PROCESSORS
protected String name
protected Integer nThreads
@ConfigurationInject protected UserExecutorConfiguration(@Nullable @Parameter String name, @Nullable Integer nThreads, @Nullable ExecutorType type, @Nullable Integer parallelism, @Nullable Integer corePoolSize, @Nullable Class<? extends ThreadFactory> threadFactoryClass)
name
- the namenThreads
- number of threadstype
- the typeparallelism
- the parallelismcorePoolSize
- the core pool sizethreadFactoryClass
- the thread factory class@NonNull public String getName()
getName
in interface ExecutorConfiguration
public ExecutorType getType()
getType
in interface ExecutorConfiguration
ExecutorType
@Min(value=1L) public @Min(value=1L) Integer getParallelism()
getParallelism
in interface ExecutorConfiguration
ExecutorType.WORK_STEALING
@Min(value=1L) public @Min(value=1L) Integer getNumberOfThreads()
getNumberOfThreads
in interface ExecutorConfiguration
ExecutorType.FIXED
@Min(value=1L) public @Min(value=1L) Integer getCorePoolSize()
getCorePoolSize
in interface ExecutorConfiguration
ExecutorType.SCHEDULED
public Optional<Class<? extends ThreadFactory>> getThreadFactoryClass()
getThreadFactoryClass
in interface ExecutorConfiguration
ThreadFactory
public void setName(String name)
name
- The namepublic void setType(ExecutorType type)
ExecutorType.SCHEDULED
).type
- The typepublic void setParallelism(Integer parallelism)
ExecutorType.WORK_STEALING
. Default value (Number of processors available to the Java virtual machine).parallelism
- The parallelismpublic void setNumberOfThreads(Integer nThreads)
ExecutorType.FIXED
. Default value (2 * Number of processors available to the Java virtual machine).nThreads
- The number of threadspublic void setCorePoolSize(Integer corePoolSize)
ExecutorType.SCHEDULED
. Default value (2 * Number of processors available to the Java virtual machine).corePoolSize
- The core pool sizepublic void setThreadFactoryClass(Class<? extends ThreadFactory> threadFactoryClass)
threadFactoryClass
- The thread factory class.public static UserExecutorConfiguration of(ExecutorType type)
UserExecutorConfiguration
for the given ExecutorType
.type
- The typepublic static UserExecutorConfiguration of(String name, ExecutorType type)
UserExecutorConfiguration
for the given ExecutorType
.name
- The nametype
- The typepublic static UserExecutorConfiguration of(ExecutorType type, int num)
UserExecutorConfiguration
for the given ExecutorType
.type
- The typenum
- The number of threads for ExecutorType.FIXED
or the parallelism for
ExecutorType.WORK_STEALING
or the core pool size for ExecutorType.SCHEDULED
public static UserExecutorConfiguration of(ExecutorType type, int num, @Nullable Class<? extends ThreadFactory> threadFactoryClass)
UserExecutorConfiguration
for the given ExecutorType
.type
- The typenum
- The number of threads for ExecutorType.FIXED
or the parallelism for
ExecutorType.WORK_STEALING
or the core pool size for ExecutorType.SCHEDULED
threadFactoryClass
- The thread factory class