Beast Logo

PrevUpHomeNext

async_completion

Helper for customizing the return type of asynchronous initiation functions.

Synopsis

Defined in header <beast/core/async_result.hpp>

template<
    class CompletionToken,
    class Signature>
struct async_completion
Types

Name

Description

completion_handler_type

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

Member Functions

Name

Description

async_completion

Constructor.

Data Members

Name

Description

completion_handler

The final completion handler, callable with the specified signature.

result

The return value of the asynchronous initiation function.

Description

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.

Example:

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

Type

Description

CompletionToken

Specifies the model used to obtain the result of the asynchronous operation.

Signature

The call signature for the completion handler type invoked on completion of the asynchronous operation.

Remarks

See Working Draft, C++ Extensions for Networking

See Also

async_return_type, handler_type

Convenience header <beast/core.hpp>


PrevUpHomeNext