Package com.scivicslab.pojoactor.core
Class ForkJoinPoolWrapper
java.lang.Object
com.scivicslab.pojoactor.core.ForkJoinPoolWrapper
- All Implemented Interfaces:
WorkerPool,AutoCloseable,Executor,ExecutorService
A WorkerPool implementation that wraps ForkJoinPool (work-stealing executor).
This is the default implementation that maintains backward compatibility
with the original POJO-actor behavior. It uses ForkJoinPool for optimal
performance with independent CPU-bound tasks.
Note: This implementation does NOT support job cancellation per actor.
Use ControllableWorkStealingPool if you need that feature.
- Since:
- 1.0.0
- Author:
- devteam@scivics-lab.com
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a ForkJoinPoolWrapper with default parallelism.ForkJoinPoolWrapper(int parallelism) Creates a ForkJoinPoolWrapper with specified parallelism. -
Method Summary
Modifier and TypeMethodDescriptionbooleanawaitTermination(long timeout, TimeUnit unit) voidinvokeAll(Collection<? extends Callable<T>> tasks) invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) <T> TinvokeAny(Collection<? extends Callable<T>> tasks) <T> TinvokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) booleanbooleanvoidshutdown()Future<?> <T> Future<T> <T> Future<T> booleanChecks if this worker pool supports job cancellation per actor.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.concurrent.ExecutorService
closeMethods inherited from interface com.scivicslab.pojoactor.core.WorkerPool
cancelJobsForActor, getPendingJobCountForActor
-
Constructor Details
-
ForkJoinPoolWrapper
public ForkJoinPoolWrapper()Creates a ForkJoinPoolWrapper with default parallelism. -
ForkJoinPoolWrapper
public ForkJoinPoolWrapper(int parallelism) Creates a ForkJoinPoolWrapper with specified parallelism.- Parameters:
parallelism- the number of worker threads
-
-
Method Details
-
supportsCancellation
public boolean supportsCancellation()Description copied from interface:WorkerPoolChecks if this worker pool supports job cancellation per actor.- Specified by:
supportsCancellationin interfaceWorkerPool- Returns:
- true if cancelJobsForActor() is supported
-
execute
-
shutdown
public void shutdown()- Specified by:
shutdownin interfaceExecutorService
-
shutdownNow
- Specified by:
shutdownNowin interfaceExecutorService
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceExecutorService
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceExecutorService
-
awaitTermination
- Specified by:
awaitTerminationin interfaceExecutorService- Throws:
InterruptedException
-
submit
- Specified by:
submitin interfaceExecutorService
-
submit
- Specified by:
submitin interfaceExecutorService
-
submit
- Specified by:
submitin interfaceExecutorService
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException - Specified by:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException - Specified by:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException - Specified by:
invokeAnyin interfaceExecutorService- Throws:
InterruptedExceptionExecutionException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
invokeAnyin interfaceExecutorService- Throws:
InterruptedExceptionExecutionExceptionTimeoutException
-