asio-grpc v3.3.0
Asynchronous gRPC with Asio/unified executors
|
(experimental) Utility class for uncancelable operations More...
#include <agrpc/waiter.hpp>
Classes | |
struct | rebind_executor |
Rebind the Waiter to another executor. More... | |
Public Types | |
using | executor_type = Executor |
The associated executor type. | |
Public Member Functions | |
Waiter () noexcept | |
Default construct a Waiter. | |
~Waiter () noexcept | |
Destruct the Waiter. | |
template<class Function , class ExecutorOrIoObject , class... Args> | |
auto | initiate (Function &&function, ExecutorOrIoObject &&executor_or_io_object, Args &&... args) |
Initiate an operation. | |
bool | is_ready () const noexcept |
Has the initiated operation finished? | |
template<class CompletionToken = detail::DefaultCompletionTokenT<Executor>> | |
auto | wait (CompletionToken &&token=CompletionToken{}) |
Wait for the initiated operation to complete. | |
(experimental) Utility class for uncancelable operations
Provides cancellation support for otherwise uncancelable operations by canceling only the act of waiting for completion as opposed to the operation itself.
Note, this is a general purpose Asio utility and as such does not belong into asio-grpc. For coroutines, Boost.Cobalt offers a replacement in the form of boost::cobalt::promise
with its interrupt wait feature.
Signature | Completion signature of the operation. For example, for agrpc::Alarm::wait this would be void(bool) . |
Executor | Type of the I/O executor. For agrpc::Alarm this would be agrpc::GrpcExecutor or asio::any_io_executor . Default: agrpc::GrpcExecutor |
|
inlinenoexcept |
|
inline |
Initiate an operation.
Only one operation may be running at a time.
All operations must complete before this object is destructed.
Example:
function
returns a sender then only the set_value
channel is forwarded to the waiting operation.function | Callable that will be invoked with all subsequent arguments followed by the completion handler of this Waiter (Asio) or it returns a sender composed of the result of the call (unifex/stdexec only). |
executor_or_io_object | Either an executor itself or an object that implements get_executor() . This will become the I/O executor of subsequent calls to wait() . |
|
inlinenodiscardnoexcept |
Has the initiated operation finished?
Thread-safe
|
inline |
Wait for the initiated operation to complete.
Only one call to wait()
may be outstanding at a time. May be called before an operation has been initiated. Care must be taken when invoking this function multiple times for an already completed operation as completion arguments are moved into the completion handler.
Per-Operation Cancellation
All. Upon cancellation, the initiated operation continues to run.