A disposable handle for an eager operation.
template< typename Signature = void(), typename Executor = asio::any_io_executor, typename Allocator = std::allocator<void>> struct promise
Name |
Description |
---|---|
The value that's returned by the promise. |
Name |
Description |
---|---|
Cancel the promise. Usually done through the destructor. |
|
Check if the promise is completed already. |
|
Wait for the promise to become ready. |
|
promise [constructor] |
|
~promise [destructor] |
Destruct the promise and cancel the operation. |
The signature of the operation.
The executor to be used by the promise (taken from the operation).
The allocator used for the promise. Can be set through use_allocator.
A promise can be used to initiate an asynchronous option that can be completed later. If the promise gets destroyed before completion, the operation gets a cancel signal and the result is ignored.
A promise fulfills the requirements of async_operation.
Reading and writing from one coroutine.
awaitable<void> read_write_some(asio::ip::tcp::socket & sock, asio::mutable_buffer read_buf, asio::const_buffer to_write) { auto p = asio::async_read(read_buf, asio::use_awaitable); co_await asio::async_write_some(to_write, asio::deferred); co_await p; }
Header: asio/experimental/promise.hpp
Convenience header: None