Package conseq4j.summon
Class ConseqServiceFactory
- java.lang.Object
-
- conseq4j.summon.ConseqServiceFactory
-
- All Implemented Interfaces:
SequentialExecutorServiceFactory,Terminable
@ThreadSafe public final class ConseqServiceFactory extends Object implements SequentialExecutorServiceFactory
A factory to produce sequential executors of typeExecutorServicewith an upper-bound global execution concurrency. Providing task execution concurrency, as well as sequencing, via theExecutorServiceAPI.- Author:
- Qingtian Wang
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ExecutorServicegetExecutorService(Object sequenceKey)booleanisTerminated()Nonblockingstatic ConseqServiceFactorynewInstance()static ConseqServiceFactorynewInstance(int concurrency)voidshutdown()Nonblocking, initiates an orderly shutdown of all managed thread resources.
-
-
-
Method Detail
-
newInstance
public static ConseqServiceFactory newInstance()
- Returns:
- ExecutorService factory with default concurrency
-
newInstance
public static ConseqServiceFactory newInstance(int concurrency)
- Parameters:
concurrency- max number of tasks possible to be executed in parallel- Returns:
- ExecutorService factory with given concurrency
-
getExecutorService
public ExecutorService getExecutorService(Object sequenceKey)
- Specified by:
getExecutorServicein interfaceSequentialExecutorServiceFactory- Parameters:
sequenceKey- anObjectinstance whose hash code is used to summon the corresponding executor.- Returns:
- a single-thread executor that does not support any shutdown action.
-
shutdown
public void shutdown()
Description copied from interface:TerminableNonblocking, initiates an orderly shutdown of all managed thread resources. Previously submitted tasks are executed, but no new tasks will be accepted. Invocation has no additional effect if already shut down.- Specified by:
shutdownin interfaceTerminable
-
isTerminated
public boolean isTerminated()
Description copied from interface:TerminableNonblocking- Specified by:
isTerminatedin interfaceTerminable- Returns:
- true if all tasks of all managed executors have completed following shut down. Note that isTerminated is never true unless shutdown was called first.
-
-