Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

eager_t::executor_with_default::default_completion_token_type

Specify eager_t as the default completion token type.

typedef eager_t< Allocator > default_completion_token_type;
Types

Name

Description

allocator_type

The allocator type. The allocator is used when constructing the shared state for a given asynchronous operation.

as_default_on_t

Type alias to adapt an I/O object to use eager_t as its default completion token type.

executor_with_default

Adapts an executor to add the eager_t completion token as the default.

Member Functions

Name

Description

as_default_on [static]

Function helper to adapt an I/O object to use eager_t as its default completion token type.

eager_t [constructor]

Construct using default-constructed allocator.
—
Construct using specified allocator.

get_allocator

Obtain allocator.

rebind

Specify an alternate allocator.

The eager object may be passed as the completion token to an asynchronous operation that has an associated I/O executor. The operation is started immediately, and the call returns an eager operation that may be waited on later. For example:

auto 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) { ... });

An operation with no associated executor, such as one produced by boost::asio::deferred::values, cannot be used with this token, as there would be nowhere to deliver the result of the wait.

Discarding the returned handle without waiting on it detaches from the operation. See basic_eager_async_operation for the requirements this places on the caller.

The optional Allocator is used to allocate the operation's shared state. It is also associated with the handler given to the underlying operation, and so is used for that operation's state as well.

Before C++17, where std::variant is unavailable, this token supports an operation with at most two completion signatures.

The token is idempotent. Applying it to an operation that has already been eagerly initiated yields that same operation, without creating a further shared state, and an allocator specified on the subsequent application is unused.

See Also

Eager operations

Requirements

Header: boost/asio/eager.hpp

Convenience header: boost/asio.hpp


PrevUpHomeNext