![]() |
Home | Libraries | People | FAQ | More |
A handle to an eagerly-initiated asynchronous operation.
typedef basic_eager_async_operation< any_io_executor, Signatures... > eager_async_operation;
|
Name |
Description |
|---|---|
|
basic_eager_async_operation [constructor] |
Move constructor. |
|
Cancel the operation. |
|
|
Wait for the operation to complete, consuming the eager operation. |
|
|
Move assignment operator. |
|
|
Whether the operation's result is ready to be taken without waiting. |
A basic_eager_async_operation
is a move-only handle to a single asynchronous operation that has already
been started. It is produced by passing the eager completion token to an asynchronous
operation, and is more conveniently named using the eager_async_operation alias.
The operation is consumed by invoking it as an rvalue, exactly once, which starts an asynchronous wait for its completion:
boost::asio::eager_async_operation< void(boost::system::error_code, std::size_t)> op = socket.async_read_some(buffer, boost::asio::eager); // ... do other work while the read runs ... std::move(op)([](boost::system::error_code e, std::size_t n) { ... });
Destroying a handle that has not been waited on detaches from the operation.
The operation is not cancelled. It continues to run, and its result is discarded.
Although the handle may be moved as necessary, ownership of the objects the
operation refers to is retained by the caller, which must guarantee that
they remain valid until the operation completes. To cancel the operation,
call cancel, or bind a cancellation
slot to the completion handler passed when waiting.
Distinct objects: Safe.
Shared objects: Unsafe.
An eager operation adds no thread safety to the operation that it wraps. A cancellation request is emitted on the thread that requests it, so it is the caller's responsibility to do so from a context that is safe with respect to the operation's execution.
A convenience alias for basic_eager_async_operation that
uses the polymorphic any_io_executor.
As the type records only the executor and the completion signatures, and
not the operation that produced it, eagerly initiated operations of different
kinds share this single type, and may be stored together or passed across
an interface that is not a template.
An operation whose executor is a concrete type, or one that alters behaviour
such as a strand, has a distinct type of its own, but converts to this one
whenever its executor converts to any_io_executor.
Header: boost/asio/eager.hpp
Convenience header: boost/asio.hpp