|
A11 (C++ runtime)
Native C++ implementation of the A11 action and streaming runtime
|
Shared handle to one asynchronous result. More...
#include <cpp/a11/concurrency/future.h>
Public Member Functions | |
| Future ()=default | |
| bool | valid () const |
| Whether this handle refers to shared completion state. | |
| bool | IsReady () const |
| Whether the producer has published either a value or an error. | |
| absl::Status | Cancel () const |
| Request cancellation from the operation producing this result. | |
| absl::StatusOr< T > | Await (absl::Time deadline=absl::InfiniteFuture()) const |
| Wait for and return the result up to an absolute deadline. | |
| void | OnReady (absl::AnyInvocable< void(const absl::StatusOr< T > &)> callback) const |
Run callback once when the result becomes available. | |
Friends | |
| class | Promise< T > |
| template<typename U > | |
| Future< U > | Submit (absl::AnyInvocable< absl::StatusOr< U >() && > work, thread::TreeOptions tree_options) |
| template<typename U > | |
| Future< U > | SubmitWithCancellationHook (absl::AnyInvocable< absl::StatusOr< U >() && > work, std::function< void()> cancellation_hook, thread::TreeOptions tree_options) |
Shared handle to one asynchronous result.
Futures are cheap to copy and may have several waiters. Await() integrates with A11 fibers when called inside the runtime and parks an ordinary thread otherwise. OnReady() is the callback-oriented path used by high-cardinality pumps and language bindings.
Cancellation is a request to the producing operation; callers must still observe the future to learn its eventual result.
|
default |
|
inline |
Wait for and return the result up to an absolute deadline.
A timeout or cancellation of the waiting fiber does not itself overwrite the producer's result; another observer may continue waiting.
|
inline |
Request cancellation from the operation producing this result.
|
inline |
Whether the producer has published either a value or an error.
|
inline |
Run callback once when the result becomes available.
The callback runs immediately when the future is already ready. It must not retain the referenced StatusOr beyond the callback invocation.
|
inline |
Whether this handle refers to shared completion state.
|
friend |
|
friend |