Package io.micronaut.scheduling.executor
Class UserExecutorConfiguration
java.lang.Object
io.micronaut.scheduling.executor.UserExecutorConfiguration
- All Implemented Interfaces:
ExecutorConfiguration
@EachProperty("micronaut.executors")
public class UserExecutorConfiguration
extends Object
implements ExecutorConfiguration
Allows configuration
ExecutorService instances that are made available as beans.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intNumber of available processors.protected Stringprotected IntegerFields inherited from interface io.micronaut.scheduling.executor.ExecutorConfiguration
PREFIX, PREFIX_CONSUMER, PREFIX_IO, PREFIX_SCHEDULED -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedUserExecutorConfiguration(@Nullable String name, @Nullable Integer nThreads, @Nullable ExecutorType type, @Nullable Integer parallelism, @Nullable Integer corePoolSize, @Nullable Boolean virtual, @Nullable Class<? extends ThreadFactory> threadFactoryClass) Default Constructor. -
Method Summary
Modifier and TypeMethodDescriptiongetName()Optional<Class<? extends ThreadFactory>>getType()booleanstatic UserExecutorConfigurationof(ExecutorType type) Construct aUserExecutorConfigurationfor the givenExecutorType.static UserExecutorConfigurationof(ExecutorType type, int num) Construct aUserExecutorConfigurationfor the givenExecutorType.static UserExecutorConfigurationof(ExecutorType type, int num, @Nullable Class<? extends ThreadFactory> threadFactoryClass) Construct aUserExecutorConfigurationfor the givenExecutorType.static UserExecutorConfigurationof(String name, ExecutorType type) Construct aUserExecutorConfigurationfor the givenExecutorType.voidsetCorePoolSize(Integer corePoolSize) Sets the core pool size forExecutorType.SCHEDULED.voidSets the executor name.voidsetNumberOfThreads(Integer nThreads) Sets the number of threads forExecutorType.FIXED.voidsetParallelism(Integer parallelism) Sets the parallelism forExecutorType.WORK_STEALING.voidsetThreadFactoryClass(Class<? extends ThreadFactory> threadFactoryClass) Sets the thread factory class.voidsetType(ExecutorType type) Sets the executor type.voidsetVirtual(boolean virtual)
-
Field Details
-
AVAILABLE_PROCESSORS
public static final int AVAILABLE_PROCESSORSNumber of available processors. -
name
-
nThreads
-
-
Constructor Details
-
UserExecutorConfiguration
@ConfigurationInject protected UserExecutorConfiguration(@Nullable @Parameter @Nullable String name, @Nullable @Nullable Integer nThreads, @Nullable @Nullable ExecutorType type, @Nullable @Nullable Integer parallelism, @Nullable @Nullable Integer corePoolSize, @Nullable @Nullable Boolean virtual, @Nullable @Nullable Class<? extends ThreadFactory> threadFactoryClass) Default Constructor.- Parameters:
name- the namenThreads- number of threadstype- the typeparallelism- the parallelismcorePoolSize- the core pool sizevirtual- whether to use virtual threadsthreadFactoryClass- the thread factory class
-
-
Method Details
-
getName
- Specified by:
getNamein interfaceExecutorConfiguration- Returns:
- The name of the component
-
getType
- Specified by:
getTypein interfaceExecutorConfiguration- Returns:
- The
ExecutorType
-
getParallelism
- Specified by:
getParallelismin interfaceExecutorConfiguration- Returns:
- The parallelism for
ExecutorType.WORK_STEALING
-
getNumberOfThreads
- Specified by:
getNumberOfThreadsin interfaceExecutorConfiguration- Returns:
- The number of threads for
ExecutorType.FIXED
-
getCorePoolSize
- Specified by:
getCorePoolSizein interfaceExecutorConfiguration- Returns:
- The core pool size for
ExecutorType.SCHEDULED
-
isVirtual
public boolean isVirtual()- Specified by:
isVirtualin interfaceExecutorConfiguration- Returns:
- Whether the pool should use virtual threads.
-
setVirtual
public void setVirtual(boolean virtual) - Parameters:
virtual- Whether the pool should use virtual threads
-
getThreadFactoryClass
- Specified by:
getThreadFactoryClassin interfaceExecutorConfiguration- Returns:
- The class to use as the
ThreadFactory
-
setName
Sets the executor name.- Parameters:
name- The name
-
setType
Sets the executor type. Default value (ExecutorType.SCHEDULED).- Parameters:
type- The type
-
setParallelism
Sets the parallelism forExecutorType.WORK_STEALING. Default value (Number of processors available to the Java virtual machine).- Parameters:
parallelism- The parallelism
-
setNumberOfThreads
Sets the number of threads forExecutorType.FIXED. Default value (2 * Number of processors available to the Java virtual machine).- Parameters:
nThreads- The number of threads
-
setCorePoolSize
Sets the core pool size forExecutorType.SCHEDULED. Default value (2 * Number of processors available to the Java virtual machine).- Parameters:
corePoolSize- The core pool size
-
setThreadFactoryClass
Sets the thread factory class.- Parameters:
threadFactoryClass- The thread factory class.
-
of
Construct aUserExecutorConfigurationfor the givenExecutorType.- Parameters:
type- The type- Returns:
- The configuration
-
of
Construct aUserExecutorConfigurationfor the givenExecutorType.- Parameters:
name- The nametype- The type- Returns:
- The configuration
-
of
Construct aUserExecutorConfigurationfor the givenExecutorType.- Parameters:
type- The typenum- The number of threads forExecutorType.FIXEDor the parallelism forExecutorType.WORK_STEALINGor the core pool size forExecutorType.SCHEDULED- Returns:
- The configuration
-
of
public static UserExecutorConfiguration of(ExecutorType type, int num, @Nullable @Nullable Class<? extends ThreadFactory> threadFactoryClass) Construct aUserExecutorConfigurationfor the givenExecutorType.- Parameters:
type- The typenum- The number of threads forExecutorType.FIXEDor the parallelism forExecutorType.WORK_STEALINGor the core pool size forExecutorType.SCHEDULEDthreadFactoryClass- The thread factory class- Returns:
- The configuration
-