Package: grails.async

## [Groovy] Interface Promise<T>

- Encapsulates the notion of a Promise, a Future-like interface designed to easy integration of asynchronous functions

  Authors:
    Graeme Rocher
  Since:
    2.3

- - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `T` | `get()` Retrieves the result, blocking until the value is available
    `T` | `get(long timeout, java.util.concurrent.TimeUnit units)` Retrieves the result, blocking until the value is available or the timeout is reached
    `Promise<T>` | `onComplete(groovy.lang.Closure callable)` Execute the given closure when the promise completes
    `Promise<T>` | `onError(groovy.lang.Closure callable)` Execute the given closure when an error occurs
    `Promise<T>` | `then(groovy.lang.Closure callable)` Same as #onComplete

- - ### Method Detail

    - #### T get()

      Retrieves the result, blocking until the value is available

      Returns:
        The result

    - #### T get(long timeout, java.util.concurrent.TimeUnit units)

      Retrieves the result, blocking until the value is available or the timeout is reached

      throws:
        Throwable
      Parameters:
        `timeout` - The timeout
        `units` - The timeout units
      Returns:
        The value

    - #### Promise<T> onComplete(groovy.lang.Closure callable)

      Execute the given closure when the promise completes

      Parameters:
        callable
      Returns:
        The Promise

    - #### Promise<T> onError(groovy.lang.Closure callable)

      Execute the given closure when an error occurs

      Parameters:
        callable
      Returns:
        The Promise

    - #### Promise<T> then(groovy.lang.Closure callable)

      Same as #onComplete