asio-grpc v1.6.0
Asynchronous gRPC with Asio/unified executors
|
(experimental) Cancellation safety for asynchronous operations More...
#include <agrpc/cancelSafe.hpp>
Public Member Functions | |
auto | token () noexcept |
Create a completion token to initiate asynchronous operations. More... | |
template<class CompletionToken > | |
auto | wait (CompletionToken token) |
Wait for the asynchronous operation to complete. More... | |
(experimental) Cancellation safety for asynchronous operations
This class provides a completion token that can be used to initiate asynchronous operations in a cancellation safe manner. A second method of this class is then used to wait for the operation to complete. Cancelling said waiting will not cancel the underlying operation but still invoke the completion handler with asio::error::operation_aborted
. This can be useful in combination with asio::parallel_group
or asio::awaitable_operators
, e.g. to perform an action every 100ms while waiting for a server-stream:
CompletionArgs | The arguments of the completion signature. E.g. for asio::steady_timer::async_wait the completion arguments would be boost::system::error_code . |
|
inlinenoexcept |
Create a completion token to initiate asynchronous operations.
The CancelSafe may not be moved while the operation is outstanding.
|
inline |
Wait for the asynchronous operation to complete.
Only one call to wait()
may be outstanding at a time. Waiting for an already completed operation will immediately invoke the completion handler in a manner equivalent to using asio::post
.
Per-Operation Cancellation
All. Upon cancellation, the asynchronous operation continues to run.
token | Completion token that matches the completion args. Either void(error_code, CompletionArgs...) if the first argument in CompletionArgs is not error_code or void(CompletionArgs...) otherwise. |