Beast Logo

PrevUpHomeNext
async_completion::completion_handler_type

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

Synopsis
using completion_handler_type = typename async_result< typename std::decay< CompletionToken >::type, Signature >::completion_handler_type;
Types

Name

Description

completion_handler_type

The concrete completion handler type for the specific signature.

return_type

The return type of the initiating function.

Member Functions

Name

Description

async_result

Construct an async result from a given handler.

get

Obtain the value to be returned from the initiating function.

This class is used for determining:

The trait allows the handler and return types to be determined at the point where the specific completion handler signature is known.

This template takes advantage of specializations of both boost::asio::async_result and boost::asio::handler_type for user-defined completion token types. The primary template assumes that the CompletionToken is the completion handler.

Example

The example shows how to define an asynchronous initiation function whose completion handler receives an error code:

template<
    class AsyncStream,          // A stream supporting asynchronous read and write
    class Handler               // The handler to call with signature void(error_code)
>
async_return_type<              // This provides the return type customization
    Handler, void(error_code)>
do_async(
    AsyncStream& stream,        // The stream to work on
    Handler&& handler)          // Could be an rvalue or const reference
{
    // Make sure we have an async stream
    static_assert(is_async_stream<AsyncWriteStream>::value,
        "AsyncStream requirements not met");

    // This helper converts the handler into the real handler type
    async_completion<WriteHandler, void(error_code)> init{handler};

    ... // Create and invoke the composed operation

    // This provides the return value and executor customization
    return init.result.get();
}
See Also

async_completion, async_return_type, handler_type

Description

Objects of this type will be callable with the specified signature.


PrevUpHomeNext