Module stormpot
Package stormpot

Interface Completion


  • public interface Completion

    A Completion represents some task that is going to be completed at some point in the future, or maybe already has completed. It is similar to Future but without any options for cancellation or returning a result. Indeed, you cannot even precisely tell if the task has already completed, but the await methods will return immediately if that is the case.

    Author:
    Chris Vest <mr.chrisvest@gmail.com>
    See Also:
    Pool.shutdown()
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      boolean await​(Timeout timeout)
      Causes the current thread to wait until the completion is finished, or the thread is interrupted, or the specified waiting time elapses.
    • Method Detail

      • await

        boolean await​(Timeout timeout)
               throws java.lang.InterruptedException

        Causes the current thread to wait until the completion is finished, or the thread is interrupted, or the specified waiting time elapses.

        If the task represented by this completion has already completed, the method immediately returns true.

        If the current thread already has its interrupted status set upon entry to this method, or the thread is interrupted while waiting, then an InterruptedException is thrown and the current threads interrupted status is cleared.

        If the specified waiting time elapses, then the method returns false.

        Parameters:
        timeout - The timeout delimiting the maximum time to wait for the task to complete. Timeouts with zero or negative values will cause the method to return immediately.
        Returns:
        true if the task represented by this completion completed within the specified waiting time, or was already complete upon entry to this method; or false if the specified Timeout elapsed before the task could finished.
        Throws:
        java.lang.InterruptedException - if the current thread is interrupted while waiting.
        java.lang.IllegalArgumentException - if the provided timeout parameter is null.