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.
- Since:
- 1.0.0
- Author:
- devteam@scivicslab.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> booleanReturns whether this implementation supports per-actor job cancellation.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:WorkerPoolReturns whether this implementation supports per-actor job cancellation.Returns
falsefor ForkJoinPool-based implementations. ReturnstrueforManagedThreadPool.- Specified by:
supportsCancellationin interfaceWorkerPool- Returns:
- true if
WorkerPool.cancelJobsForActor(String)actually removes jobs
-
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
-