Package com.scivicslab.pojoactor.core
Interface WorkerPool
- All Superinterfaces:
AutoCloseable,Executor,ExecutorService
- All Known Implementing Classes:
ControllableWorkStealingPool,ForkJoinPoolWrapper
Interface for worker pools that execute CPU-bound jobs for actors.
This interface abstracts two implementation strategies:
1. ForkJoinPool-based (work-stealing, default)
2. ControllableWorkStealingPool (ThreadPoolExecutor-based with job cancellation)
Implementations must provide ExecutorService compatibility for use with
ActorRef.tell(action, pool) and ActorRef.ask(action, pool).
- Since:
- 1.0.0
- Author:
- devteam@scivics-lab.com
-
Method Summary
Modifier and TypeMethodDescriptiondefault intcancelJobsForActor(String actorName) Cancels all pending jobs for a specific actor.default intgetPendingJobCountForActor(String actorName) Gets the number of pending jobs for a specific actor.default booleanChecks if this worker pool supports job cancellation per actor.Methods inherited from interface java.util.concurrent.ExecutorService
awaitTermination, close, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated, shutdown, shutdownNow, submit, submit, submit
-
Method Details
-
cancelJobsForActor
Cancels all pending jobs for a specific actor. Jobs that are already running will continue to completion.- Parameters:
actorName- the name of the actor whose jobs should be cancelled- Returns:
- the number of jobs that were cancelled
-
getPendingJobCountForActor
Gets the number of pending jobs for a specific actor.- Parameters:
actorName- the name of the actor- Returns:
- the number of pending jobs
-
supportsCancellation
default boolean supportsCancellation()Checks if this worker pool supports job cancellation per actor.- Returns:
- true if cancelJobsForActor() is supported
-