Interface IEolContextParallel

    • Field Detail

      • NUM_THREADS_CONFIG

        static final String NUM_THREADS_CONFIG
        The key used for configuring the parallelism in dt plugins.
        See Also:
        Constant Field Values
    • Method Detail

      • getParallelism

        int getParallelism()
        Indicates the scalability of this Context when more processing nodes are added.
        Returns:
        the number of threads.
      • isParallel

        boolean isParallel()
        This method will return true if #beginParallelTask() has been called and false if endParallelTask() has been called, or if #beginParallelTask() has not been called yet.
        Returns:
        Whether this Context is currently executing in parallel mode.
      • isParallelisationLegal

        default boolean isParallelisationLegal()
        Convenience method for testing whether to perform an operation in parallel using this context without encountering an EolNestedParallelismException.
        Returns:
        true if calling #enterParallelNest(ModuleElement) is permitted.
      • ensureNotNested

        default void ensureNotNested​(ModuleElement entryPoint)
                              throws EolNestedParallelismException
        This method should be called prior to performing any parallel execution.
        Parameters:
        entryPoint - The module element to use as the cause of an exception
        Throws:
        EolNestedParallelismException - If #isParallelisationLegal(Object) returns false
      • executeAll

        default <T> List<T> executeAll​(ModuleElement entryPoint,
                                       Collection<? extends Callable<? extends T>> jobs)
                                throws EolRuntimeException
        Executes all of the tasks in parallel, blocking until they have completed. The returned Collection is ordered based on the same ordering of the input Collection.
        Type Parameters:
        T - The return type for each job.
        Parameters:
        entryPoint - The identifier for this parallel task.
        jobs - The transformations to perform.
        Returns:
        The result of the jobs in encounter order.
        Throws:
        EolRuntimeException - If any of the jobs fail (i.e. throw an exception).
      • executeAny

        default <T> T executeAny​(ModuleElement entryPoint,
                                 Collection<? extends Callable<? extends T>> jobs)
                          throws EolRuntimeException
        Submits all jobs and waits until either all jobs have completed, or #completeShortCircuit(ModuleElement, Object) is called.
        Type Parameters:
        T - The return type of each job.
        Parameters:
        entryPoint - The identifier for this parallel task.
        jobs - The jobs to execute.
        Returns:
        The result of this task, as set by #completeShortCircuit(ModuleElement, Object), if any.
        Throws:
        EolRuntimeException - If any of the jobs fail (i.e. throw an exception).
      • configureContext

        static <C extends IEolContextParallel> C configureContext​(Map<String,​?> properties,
                                                                  Function<Integer,​? extends C> contextConstructor,
                                                                  C currentContext)
                                                           throws IllegalArgumentException
        Convenience method for setting the parallelism on a context.
        Parameters:
        properties - The parameter passed to the configure method of the module.
        contextConstructor - The function which creates a parallel context from a given number of threads.
        currentContext - The existing context to return, if no changes are made.
        Returns:
        The new context if NUM_THREADS_CONFIG is present in the properties, otherwise currentContext.
        Throws:
        IllegalArgumentException - If the value of NUM_THREADS_CONFIG property is invalid.