Class IndifferentFactoryOfTheFuture

java.lang.Object
space.arim.omnibus.util.concurrent.impl.AbstractFactoryOfTheFuture
space.arim.omnibus.util.concurrent.impl.IndifferentFactoryOfTheFuture
All Implemented Interfaces:
Executor, FactoryOfTheFuture, SynchronousExecutor

public class IndifferentFactoryOfTheFuture extends AbstractFactoryOfTheFuture
FactoryOfTheFuture implementation which regards Sync method calls to the CentralisedFutures produced by the factory as identical to Async calls using the default executor.

Specifically, this implementation produces IndifferentCentralisedFutures. It is suitable for applications where there is no "main" or "primary" thread. Calls to executeSync(Runnable) are treated identically as those to AbstractFactoryOfTheFuture.execute(Runnable).
Author:
A248
  • Constructor Details

    • IndifferentFactoryOfTheFuture

      public IndifferentFactoryOfTheFuture()
  • Method Details

    • newIncompleteFuture

      public <U> CentralisedFuture<U> newIncompleteFuture()
      Description copied from class: AbstractFactoryOfTheFuture
      Creates a new, incomplete future. The result of this method is used in implementing various FactoryOfTheFuture specifications.
      Specified by:
      newIncompleteFuture in interface FactoryOfTheFuture
      Specified by:
      newIncompleteFuture in class AbstractFactoryOfTheFuture
      Type Parameters:
      U - the result type of the future
      Returns:
      a new incomplete future
    • executeSync

      public void executeSync(Runnable command)
      Description copied from interface: FactoryOfTheFuture
      Runs the Runnable on the main thread, if the application has a main thread, else executes it in a thread pool suitable for computational work such as ForkJoinPool.commonPool()
      Parameters:
      command - the runnable to run synchronously with the main thread