public class ForkJoinActionEngine extends AbstractActionEngine
ActionEngine
based on ForkJoinPool
. Scheduling is achieved
using ForkJoinPool.managedBlock(ManagedBlocker)
so many threads may be used but not all
executing Action
.ForkJoinPool.commonPool()
that cannot
be stopped or paused (commonPoolEngine()
).Modifier and Type | Class and Description |
---|---|
class |
ForkJoinActionEngine.ForkJoinContext<T>
Fork join context.
|
executorService, TERMINATION_TIMEOUT
Constructor and Description |
---|
ForkJoinActionEngine()
Creates a new ForkJoinActionEngine instance with the default parallelism.
|
ForkJoinActionEngine(int parallelism)
Creates a new ForkJoinActionEngine with the supplied parallelism.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
addWork(ForkJoinActionEngine.ForkJoinContext<?> context)
Adds work to the engine.
|
protected void |
addWorkerIfNeeded()
Starts a worker if needed (waiting work and no free workers).
|
static ForkJoinActionEngine |
commonPoolEngine()
Gets the common ForkJoinActionEngine instance backed by
ForkJoinPool.commonPool()
(this cannot be paused or stopped). |
protected ManualWorkQueue<ForkJoinActionEngine.ForkJoinContext<?>> |
getWorkQueue()
Gets the engine's work queue.
|
<T> ForkJoinActionEngine.ForkJoinContext<T> |
newContext(Action<T> action)
Creates an action context to define how the action will be scheduled for execution.
|
protected boolean |
removeWork(ForkJoinActionEngine.ForkJoinContext<?> context)
Removes work from the engine.
|
void |
stop()
Permanently stops the engine.
|
awaitResumed, getBindings, isPaused, isStopped, pause, resume
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
putInBindings, removeFromBindings, schedule, schedule
public ForkJoinActionEngine()
Runtime.availableProcessors()
public ForkJoinActionEngine(int parallelism)
parallelism
- The parallelism level.public static ForkJoinActionEngine commonPoolEngine()
ForkJoinPool.commonPool()
(this cannot be paused or stopped).protected boolean addWork(ForkJoinActionEngine.ForkJoinContext<?> context)
context
- Work to add.Actions.requireNotStopped(ActionEngine)
protected void addWorkerIfNeeded()
protected ManualWorkQueue<ForkJoinActionEngine.ForkJoinContext<?>> getWorkQueue()
public <T> ForkJoinActionEngine.ForkJoinContext<T> newContext(Action<T> action)
ActionEngine
action
- Action to create context for.protected boolean removeWork(ForkJoinActionEngine.ForkJoinContext<?> context)
context
- Work to remove.public void stop()
ActionEngine
stop
in interface ActionEngine
stop
in class AbstractActionEngine