Class BackgroundOperation<T>


  • public class BackgroundOperation<T>
    extends java.lang.Object
    Class for running an Operation in the background in a separate thread. The operation is executed using the ExecutorService retrieved from ApfloatContext.getExecutorService().
    Version:
    1.14.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.concurrent.Future<T> future  
    • Constructor Summary

      Constructors 
      Constructor Description
      BackgroundOperation​(Operation<T> operation)
      Runs an operation in the background in a separate thread.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cancel()
      Cancel the operation by interrupting the thread executing it.
      T getResult()
      Get the result of the operation.
      boolean isFinished()
      Check if the operation has been completed.
      • Methods inherited from class java.lang.Object

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

      • future

        private java.util.concurrent.Future<T> future
    • Constructor Detail

      • BackgroundOperation

        public BackgroundOperation​(Operation<T> operation)
        Runs an operation in the background in a separate thread. The execution is started immediately.
        Parameters:
        operation - The operation to execute.
    • Method Detail

      • isFinished

        public boolean isFinished()
        Check if the operation has been completed.
        Returns:
        true if the execution of the operation has been completed, otherwise false.
      • cancel

        public void cancel()
        Cancel the operation by interrupting the thread executing it.
        Since:
        1.14.0
      • getResult

        public T getResult()
        Get the result of the operation. This method blocks until the operation has been completed.
        Returns:
        Result of the operation.
        Throws:
        java.lang.RuntimeException - If an exception was thrown by the executed operation.