Class ParallelizedAction

  • All Implemented Interfaces:
    java.io.Serializable, java.util.concurrent.Future<java.lang.Void>

    public abstract class ParallelizedAction
    extends java.util.concurrent.RecursiveAction
    Base class for parallel actions over contiguous int intervals.
    Author:
    anders.gidenstam(at)hb.se
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      ParallelizedAction​(int first, int last)
      Constructs a set of actions for the interval [first, last).
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void compute()
      Inherited from RecursiveAction.
      protected abstract void compute​(int i)
      The action to be performed for index i.
      protected abstract ParallelizedAction createSubtask​(int first, int last)
      Creates a ParallelizedAction for the sub-interval.
      protected void finalize​(int first, int last)
      Performs any needed finalization for the sub-interval once all sequential compute(i) calls for it has been completed.
      protected void initialize​(int first, int last)
      Performs any needed intialization for the sub-interval once the split threshold has been reached.
      void start()
      Starts this set of actions.
      • Methods inherited from class java.util.concurrent.RecursiveAction

        exec, getRawResult, setRawResult
      • Methods inherited from class java.util.concurrent.ForkJoinTask

        adapt, adapt, adapt, cancel, compareAndSetForkJoinTaskTag, complete, completeExceptionally, fork, get, get, getException, getForkJoinTaskTag, getPool, getQueuedTaskCount, getSurplusQueuedTaskCount, helpQuiesce, inForkJoinPool, invoke, invokeAll, invokeAll, invokeAll, isCancelled, isCompletedAbnormally, isCompletedNormally, isDone, join, peekNextLocalTask, pollNextLocalTask, pollSubmission, pollTask, quietlyComplete, quietlyInvoke, quietlyJoin, reinitialize, setForkJoinTaskTag, tryUnfork
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ParallelizedAction

        public ParallelizedAction​(int first,
                                  int last)
        Constructs a set of actions for the interval [first, last).
        Parameters:
        first - the first index
        last - the index after the last index in the interval
    • Method Detail

      • start

        public void start()
        Starts this set of actions.
      • initialize

        protected void initialize​(int first,
                                  int last)
        Performs any needed intialization for the sub-interval once the split threshold has been reached. E.g. allocating buffers that can be reused by the sequential compute(i) calls in this task.
        Parameters:
        first - the first index in the sub-interval
        last - the index after the last index in the sub-interval
      • finalize

        protected void finalize​(int first,
                                int last)
        Performs any needed finalization for the sub-interval once all sequential compute(i) calls for it has been completed.
        Parameters:
        first - the first index in the sub-interval
        last - the index after the last index in the sub-interval
      • compute

        protected abstract void compute​(int i)
        The action to be performed for index i.
        Parameters:
        i - the index in the interval
      • createSubtask

        protected abstract ParallelizedAction createSubtask​(int first,
                                                            int last)
        Creates a ParallelizedAction for the sub-interval.
        Parameters:
        first - the first index in the sub-interval
        last - the index after the last index in the sub-interval
        Returns:
        a new subtask in the form of a ParallelizedAction.
      • compute

        protected final void compute()
        Inherited from RecursiveAction. Do not overrride.
        Specified by:
        compute in class java.util.concurrent.RecursiveAction