|
cxxmcp 1.1.6
C++ MCP SDK
|
A thread-safe, CV-based future that replaces std::promise/shared_future. More...
#include <async_result.hpp>
Public Types | |
| using | ResultType = Result< T > |
Public Member Functions | |
| AsyncResult (const AsyncResult &)=delete | |
| AsyncResult & | operator= (const AsyncResult &)=delete |
| void | set_value (T value) |
| Set the result value. | |
| void | set_error (Error error) |
| Set an error result. Notifies all waiters and fires continuations. | |
| void | cancel (std::string reason={}) |
| Cancel the result with a cancellation error. Notifies all waiters. | |
| void | set_exception (std::exception_ptr ex) |
| Set the result from an exception_ptr. | |
| ResultType | wait () const |
| Block until the result is available. CV-based, no polling. | |
| ResultType | wait_for (std::chrono::milliseconds timeout) const |
| Block until the result is available or the timeout expires. | |
| ResultType | wait_until (std::chrono::steady_clock::time_point deadline) const |
| Block until the result is available or the deadline is reached. | |
| bool | ready () const |
| Returns true if the result has been set. | |
| template<class F > | |
| auto | then (F &&callback) -> std::shared_ptr< AsyncResult< std::invoke_result_t< F, ResultType > > > |
| Chain a continuation that fires when the result is set. | |
A thread-safe, CV-based future that replaces std::promise/shared_future.
AsyncResult<T> provides condition-variable-based waiting (no polling), cancellation support, and optional continuation chaining via then().
| T | The value type. The result is always stored as Result<T>. |
|
inline |
Set the result value.
Notifies all waiters and fires continuations. Must be called at most once.
|
inline |
Chain a continuation that fires when the result is set.
If the result is already set, the callback fires immediately on the calling thread. Otherwise it is stored and invoked on the thread that calls set_value/set_error/cancel.
| F | Callable with signature R(Result<T>). |