Package com.atlassian.bitbucket.scm
Interface AsyncCommand<T>
- Type Parameters:
T- the type of value that the operation will produce.
public interface AsyncCommand<T>
Wraps an operation which may be run
asynchronously or synchronously. When run
asynchronously, execution and idle timeouts must be applied by the calling code; they are not built in.
When the operation completes, it will return an object of type T. If T is Void, the operation
will return null on completion. Typically this means the operation uses some form of callback, allowing the
caller to process the results as they are produced rather than returning them on completion.
-
Method Summary
-
Method Details
-
start
Starts the operation and returns aFuture, which can be used to cancel the operation or block until it has finished.- Returns:
- a
Futureinstance for the operation result - Throws:
IllegalStateException- if thisAsyncCommandhas been transformed tosynchronous()
-
synchronous
Transforms thisAsyncCommandinto aCommandwhich may be called synchronously. Timeouts may be set on the returnedCommandbefore it is called.Once an
AsyncCommandhas been transformed for synchronous use, it may no longer be usedasynchronously.- Returns:
- a
Commandfor running the operation embodied by thisAsyncCommandsynchronously
-