Beast Logo

PrevUpHomeNext

async_completion

Helper for customizing the return type of asynchronous initiation functions.

template<
    class CompletionHandler,
    class Signature>
struct async_completion
Types

Name

Description

handler_type

The type of the final handler called by the asynchronous initiation function.

result_type

The type of the value returned by the asynchronous initiation function.

Member Functions

Name

Description

async_completion

Construct the helper.

Data Members

Name

Description

handler

The final completion handler, callable with the specified signature.

result

The return value of the asynchronous initiation function.

This class template is used to transform caller-provided completion handlers in calls to asynchronous initiation functions. The transformation allows customization of the return type of the initiating function, and the function signature of the final handler.

CompletionHandler

A completion handler, or a user defined type with specializations for customizing the return type (for example, boost::asio::use_future or boost::asio::yield_context).

Signature

The callable signature of the final completion handler.

Example:

...
template<class CompletionHandler>
typename async_completion<CompletionHandler,
    void(error_code)>::result_type
async_initfn(..., CompletionHandler&& handler)
{
    async_completion<CompletionHandler,
        void(error_code)> completion{handler};
    ...
    return completion.result.get();
}
Remarks

See Library Foundations For Asynchronous Operations

Requirements

Header: beast/core/async_completion.hpp

Convenience header: beast/core.hpp


PrevUpHomeNext