Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | METHOD | DETAIL: FIELD | METHOD

## grails.async
[Groovy] Interface Promise

    @groovy.transform.CompileStatic
    interface Promise

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

Authors:
  Graeme Rocher

Since:
  2.3

Method Summary
`java.lang.Object` | `get()` Retrieves the result, blocking until the value is available
`java.lang.Object` | `get(long timeout, java.util.concurrent.TimeUnit units)` Retrieves the result, blocking until the value is available or the timeout is reached
`Promise` | `onComplete(groovy.lang.Closure callable)` Execute the given closure when the promise completes
`Promise` | `onError(groovy.lang.Closure callable)` Execute the given closure when an error occurs
`Promise` | `then(groovy.lang.Closure callable)` Same as #onComplete

Method Detail

### get

    java.lang.Object get()

  Retrieves the result, blocking until the value is available
  Returns:
    The result

### get

    java.lang.Object 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

### onComplete

    Promise onComplete(groovy.lang.Closure callable)

  Execute the given closure when the promise completes
  Parameters:
    callable
  Returns:
    The Promise

### onError

    Promise onError(groovy.lang.Closure callable)

  Execute the given closure when an error occurs
  Parameters:
    callable
  Returns:
    The Promise

### then

    Promise then(groovy.lang.Closure callable)

  Same as #onComplete

Groovy Documentation