Hi everyone,
I’ve recently been experimenting with a way to eliminate the need for users to explicitly specify when to use parallel operations. The only reason to avoid using parallel operations, except for the rare case where selectOne must return the first element which matches the criteria in an ordered collection and where global state is mutated, is to avoid nesting. However since IEolContextParallel can already detect illegal nesting and throw an exception, would it not make sense to only apply parallelisation when there is no nesting?
More concretely, the only change required is to AbstractOperation.getOperationFor as shown in [1]. From the user’s point of view, there would be three ways of invoking an operation. To demonstrate, consider “select” as an example:
- .parallelSelect -> delegates to ParallelSelectOperation
- .sequentialSelect -> delegates to SelectOperation
- . select -> delegates to ParallelSelectOperation if it is not being invoked from a parallel operation – in simpler terms, if Thread.currentThread().getName().equals(“main”) – otherwise delegates to SelectOperation.
Therefore the default automatically chooses the appropriate one. However the user can also explicitly specify which implementation they want if they desire. Currently I have a prototype with additional tests (specifically org.eclipse.epsilon.eol.engine.test.acceptance.firstOrder.nested.AutoParallelOperationTests) in the parallel-epsilon branch.
Please let me know if there are any suggestions. If there are no objections I propose to merge this into the main branch.
Thanks,
Sina
[1] https://git.eclipse.org/c/epsilon/org.eclipse.epsilon.git/tree/plugins/org.eclipse.epsilon.eol.engine/src/org/eclipse/epsilon/eol/execute/operations/EolOperationFactory.java?h=parallel-epsilon