@EachProperty(value="micronaut.executors") public class UserExecutorConfiguration extends java.lang.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 java.lang.Integer |
nThreads |
PREFIX, PREFIX_CONSUMER, PREFIX_IO, PREFIX_SCHEDULED
Modifier | Constructor and Description |
---|---|
protected |
UserExecutorConfiguration()
Default Constructor.
|
Modifier and Type | Method and Description |
---|---|
@Min(value=1L) java.lang.Integer |
getCorePoolSize() |
@Min(value=1L) java.lang.Integer |
getNumberOfThreads() |
@Min(value=1L) java.lang.Integer |
getParallelism() |
java.util.Optional<java.lang.Class<? extends java.util.concurrent.ThreadFactory>> |
getThreadFactoryClass() |
ExecutorType |
getType() |
static UserExecutorConfiguration |
of(ExecutorType type)
Construct a
UserExecutorConfiguration for the given ExecutorType . |
static UserExecutorConfiguration |
of(ExecutorType type,
int num)
Construct a
UserExecutorConfiguration for the given ExecutorType . |
static UserExecutorConfiguration |
of(ExecutorType type,
int num,
java.lang.Class<? extends java.util.concurrent.ThreadFactory> threadFactoryClass)
Construct a
UserExecutorConfiguration for the given ExecutorType . |
void |
setCorePoolSize(java.lang.Integer corePoolSize)
Sets the core pool size for
ExecutorType.SCHEDULED . |
void |
setNumberOfThreads(java.lang.Integer nThreads)
Sets the number of threads for
ExecutorType.FIXED . |
void |
setParallelism(java.lang.Integer parallelism)
Sets the parallelism for
ExecutorType.WORK_STEALING . |
void |
setThreadFactoryClass(java.lang.Class<? extends java.util.concurrent.ThreadFactory> threadFactoryClass)
Sets the thread factory class.
|
void |
setType(ExecutorType type)
Sets the executor type.
|
public static final int AVAILABLE_PROCESSORS
protected java.lang.Integer nThreads
protected UserExecutorConfiguration()
public ExecutorType getType()
getType
in interface ExecutorConfiguration
ExecutorType
@Min(value=1L) public @Min(value=1L) java.lang.Integer getParallelism()
getParallelism
in interface ExecutorConfiguration
ExecutorType.WORK_STEALING
@Min(value=1L) public @Min(value=1L) java.lang.Integer getNumberOfThreads()
getNumberOfThreads
in interface ExecutorConfiguration
ExecutorType.FIXED
@Min(value=1L) public @Min(value=1L) java.lang.Integer getCorePoolSize()
getCorePoolSize
in interface ExecutorConfiguration
ExecutorType.SCHEDULED
public java.util.Optional<java.lang.Class<? extends java.util.concurrent.ThreadFactory>> getThreadFactoryClass()
getThreadFactoryClass
in interface ExecutorConfiguration
ThreadFactory
public void setType(ExecutorType type)
ExecutorType.SCHEDULED
).type
- The typepublic void setParallelism(java.lang.Integer parallelism)
ExecutorType.WORK_STEALING
. Default value (Number of processors available to the Java virtual machine).parallelism
- The parallelismpublic void setNumberOfThreads(java.lang.Integer nThreads)
ExecutorType.FIXED
. Default value (2 * Number of processors available to the Java virtual machine).nThreads
- The number of threadspublic void setCorePoolSize(java.lang.Integer corePoolSize)
ExecutorType.SCHEDULED
. Default value (2 * Number of processors available to the Java virtual machine).corePoolSize
- The core pool sizepublic void setThreadFactoryClass(java.lang.Class<? extends java.util.concurrent.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 java.lang.Class<? extends java.util.concurrent.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