public interface

AsyncCommand

com.atlassian.bitbucket.scm.AsyncCommand<T>

Class Overview

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.

Summary

Public Methods
@Nonnull Future<T> start()
Starts the operation and returns a Future, which can be used to cancel the operation or block until it has finished.
@Nonnull Command<T> synchronous()
Transforms this AsyncCommand into a Command which may be called synchronously.

Public Methods

@Nonnull public Future<T> start ()

Starts the operation and returns a Future, which can be used to cancel the operation or block until it has finished.

Returns
  • a Future instance for the operation result
Throws
IllegalStateException if this AsyncCommand has been transformed to synchronous()

@Nonnull public Command<T> synchronous ()

Transforms this AsyncCommand into a Command which may be called synchronously. Timeouts may be set on the returned Command before it is called.

Once an AsyncCommand has been transformed for synchronous use, it may no longer be used asynchronously.

Returns
  • a Command for running the operation embodied by this AsyncCommand synchronously