@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.String |
name |
protected java.lang.Integer |
nThreads |
PREFIX, PREFIX_CONSUMER, PREFIX_IO, PREFIX_SCHEDULED| Modifier | Constructor and Description |
|---|---|
protected |
UserExecutorConfiguration(java.lang.String name,
java.lang.Integer nThreads,
ExecutorType type,
java.lang.Integer parallelism,
java.lang.Integer corePoolSize,
java.lang.Class<? extends java.util.concurrent.ThreadFactory> threadFactoryClass)
Default Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
@Min(value=1L) java.lang.Integer |
getCorePoolSize() |
java.lang.String |
getName() |
@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. |
static UserExecutorConfiguration |
of(java.lang.String name,
ExecutorType type)
Construct a
UserExecutorConfiguration for the given ExecutorType. |
void |
setCorePoolSize(java.lang.Integer corePoolSize)
Sets the core pool size for
ExecutorType.SCHEDULED. |
void |
setName(java.lang.String name)
Sets the executor name.
|
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.String name
protected java.lang.Integer nThreads
@Inject protected UserExecutorConfiguration(@Nullable @Parameter java.lang.String name, @Nullable java.lang.Integer nThreads, @Nullable ExecutorType type, @Nullable java.lang.Integer parallelism, @Nullable java.lang.Integer corePoolSize, @Nullable java.lang.Class<? extends java.util.concurrent.ThreadFactory> threadFactoryClass)
name - the namenThreads - number of threadstype - the typeparallelism - the parallelismcorePoolSize - the core pool sizethreadFactoryClass - the thread factory class@NonNull public java.lang.String getName()
getName in interface ExecutorConfigurationpublic ExecutorType getType()
getType in interface ExecutorConfigurationExecutorType@Min(value=1L) public @Min(value=1L) java.lang.Integer getParallelism()
getParallelism in interface ExecutorConfigurationExecutorType.WORK_STEALING@Min(value=1L) public @Min(value=1L) java.lang.Integer getNumberOfThreads()
getNumberOfThreads in interface ExecutorConfigurationExecutorType.FIXED@Min(value=1L) public @Min(value=1L) java.lang.Integer getCorePoolSize()
getCorePoolSize in interface ExecutorConfigurationExecutorType.SCHEDULEDpublic java.util.Optional<java.lang.Class<? extends java.util.concurrent.ThreadFactory>> getThreadFactoryClass()
getThreadFactoryClass in interface ExecutorConfigurationThreadFactorypublic void setName(java.lang.String name)
name - The namepublic 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(java.lang.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.SCHEDULEDpublic 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.SCHEDULEDthreadFactoryClass - The thread factory class