-
Notifications
You must be signed in to change notification settings - Fork 24
Picking an ActionEngine implementation
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:
- AbstractActionEngine is an ActionEngine for use with ExecutorService.
- AbstracFutureActionContext is a SchedulableActionContext for use with Future.
- AbstractManualActionContext is a SchedulableActionContext for manual ticking.
Most default implementations make use of DefaultActionBindings for their SchedulableActionContext implementations and engine bindings.
Check out the Example projects and Code snippets!
Getting Started
- Getting the latest release
- Building from source
- Example projects
- Code snippets
- How to contribute
- Have bugs or questions?
How To Use
- JALSE
- Entities
- Attributes
- Actions
- Tags
Misc