Fluxtion supports parallel processing of trigger operations to reduce total response times for long running operations.
A divide and conquer approach for parallel processing is supported:
Add the attribute parallelExecution = true to an OnTrigger annotated method
Gather the nodes with parallel trigger methods into a child node
Fluxtion will use the standard ForkJoin pool to execute the trigger tasks in parallel
The gathering node will not be notified until all parent operations have completed
The total response time will be reduced if the parallel tasks take a sufficiently long time
The example main runs synchronous and asynchronous tests, executing the application produces a set of results for
both parallel and synchronously execution, displayed as an ascii bar graph.
A TaskCollector collects the results from a list of
parent SimulatedTasks nodes, that either run in parallel or synchronously.
The tasks are triggered by a RequestHandler that handles String events.
Calling eventProcessor.onEvent(“”) will cause the processor to trigger node execution starting with the ResponseHandler.
Marking parallel OnTrigger methods
The OnTrigger annotation controls the parallel execution of the trigger task:
The Main class builds the graphs for both cases and executes the processors,
collecting and printing results. Relevant excerpts of the main method show how two processors are built, one with
synchronous tasks and the other with asynchronous.
The execution graph image shows a set of tasks are triggered from the RequestHandler instance and their outputs are
gathered in the TaskCollector instance.
Running the example
The ascii bar chart clearly shows the parallel task test completes in 257ms vs 690ms for the synchronous version, using
the ForkJoin thread pool to execute task in parallel. The synchronous version executes all tasks on the main thread
serially executing each task
Y-axis - (task name) (thread name)
X-Axis - elapsed time
Running the example in Debug
To see detailed task processing set the debug log flag
This will prodice the debug output with thread execution id’s in the log messages for the SimulatedTasks