@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 Integer |
nThreads |
PREFIX, PREFIX_CONSUMER, PREFIX_IO, PREFIX_SCHEDULED
Modifier | Constructor and Description |
---|---|
protected |
UserExecutorConfiguration()
Default Constructor.
|
public static final int AVAILABLE_PROCESSORS
protected Integer nThreads
protected UserExecutorConfiguration()
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 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(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