Class ParallelExecutionStrategy

java.lang.Object
org.apfloat.internal.ParallelExecutionStrategy
All Implemented Interfaces:
ExecutionStrategy

public class ParallelExecutionStrategy extends Object implements ExecutionStrategy
Execution strategy using the ParallelRunner.
Since:
1.9.0
Version:
1.9.0
Author:
Mikko Tommila
  • Constructor Details

    • ParallelExecutionStrategy

      public ParallelExecutionStrategy()
  • Method Details

    • wait

      public void wait(Future<?> future)
      Description copied from interface: ExecutionStrategy
      While waiting for a Future to be completed, steal work from any running tasks and run it.

      While this method may functionally appear to be equivalent to just calling future.get() it should try its best to steal work from any other tasks submitted to the ExecutorService of the current ApfloatContext. It may in fact steal work using multiple threads, if the current ApfloatContext specifies numberOfProcessors to be more than one.

      The purpose of this method is to allow keeping all threads of the ExecutorService (and CPU cores) maximally busy at all times, while also not running an excessive number of parallel threads (only as many threads as there are CPU cores).

      Specified by:
      wait in interface ExecutionStrategy
      Parameters:
      future - The Future to wait for.