Skip to content

Picking an ActionEngine implementation

Elliot Ford edited this page Apr 14, 2015 · 6 revisions

What is an ActionEngine?

An ActionEngine is used to schedule and execute Actions. It does this by providing an ActionContext bound to that Action and the engine itself (see Scheduling, awaiting and cancelling actions for more information).

The default ActionEngine

Java 8 offers a common ForkJoinPool that be can used as the default pool for ForkJoinTasks. With this available JALSE provides a wrapper for this pool using ForkJoinActionEngine: ForkJoinActionengine.commonPoolEngine(). The default EntityFactory and JALSEBuilder use this common engine instance.

ForkJoinActionEngine (see API docs) is built upon ForkJoinPool and it does this using ForkJoinPool.managedBlock(ForkJoinPool.ManagedBlocker). ForkJoinActionEngine uses a blocking task that will wake up when the schedule execution time arrives (only active when there is waiting work).

ThreadPoolActionEngine (see API docs) is built upon ScheduledThreadPoolExecutor (which lends itself to the ActionEngine).

ManualActionEngine (see API docs) is an ActionEngine that must be manually ticked using ActionEngine.resume(). All scheduling still applies so tasks awaiting execution will not be ran unless execution time has passed. This should be used for creating a data model that is updated using tick cycles or one that is ticked by an external system.

Creating a custom ActionEngine implementation

For creating a custom ActionEngine there are some abstract part way components that can be used for assistance:

Most default implementations make use of DefaultActionBindings for their MutableActionContext implementations and engine bindings.

Clone this wiki locally