Interface ICompletionSync

All Known Implementing Classes:
AQueryRunner.SyncCompletionSync, CompletionSync, ForkJoinPoolNonStealableCompletionSync, QueryPartitionTaskCompleter

public interface ICompletionSync
A synchronization Object associated with a task that can be used to wait for the task to complete.

This is often returned as a result of a void method that is performing asynchronous work, so that the caller can wait for the work to be done and be informed of any exception that might have aroused.

Author:
ActiveViam
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Waits if necessary for the associated task to complete.
    void
    awaitCompletion(long timeout, TimeUnit unit)
    Waits if necessary for at most the given time for the associated task to complete.
    default void
    Waits if necessary for at most the given time for the associated task to complete.
    boolean
    Returns true if the task completed.
  • Method Details

    • isDone

      boolean isDone()
      Returns true if the task completed.

      Completion may be due to normal termination, an exception, or cancellation -- in all of these cases, this method will return true.

      Returns:
      true if the task completed
    • awaitCompletion

      void awaitCompletion()
      Waits if necessary for the associated task to complete.

      This method will re-throw any exception encountered during the execution of the task, possibly wrapped in a RuntimeException.

    • awaitCompletion

      void awaitCompletion(long timeout, TimeUnit unit) throws TimeoutException
      Waits if necessary for at most the given time for the associated task to complete.

      This method will re-throw any exception encountered during the execution of the task, possibly wrapped in a RuntimeException.

      Reaching the timeout will cause the query tasks to be cancelled.

      Parameters:
      timeout - The maximum time to wait
      unit - The time unit of the timeout argument
      Throws:
      TimeoutException - if the wait timed out
    • awaitCompletion

      default void awaitCompletion(Duration duration) throws TimeoutException
      Waits if necessary for at most the given time for the associated task to complete.

      This method will re-throw any exception encountered during the execution of the task, possibly wrapped in a RuntimeException.

      Reaching the timeout will cause the query tasks to be cancelled.

      Parameters:
      duration - The maximum time to wait
      Throws:
      TimeoutException - if the wait timed out