ゴミ箱
Public Types | Public Member Functions | List of all members
boost::beast::async_result< CompletionToken, Signature > Class Template Reference

#include <async_result.hpp>

Public Types

using completion_handler_type = typename boost::asio::handler_type< CompletionToken, Signature >::type
 The concrete completion handler type for the specific signature. More...
 
using return_type = typename boost::asio::async_result< completion_handler_type >::type
 The return type of the initiating function. More...
 

Public Member Functions

 async_result (completion_handler_type &h)
 
return_type get ()
 Obtain the value to be returned from the initiating function. More...
 

Detailed Description

template<class CompletionToken, class Signature>
class boost::beast::async_result< CompletionToken, Signature >

An interface for customising the behaviour of an asynchronous initiation 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

Member Typedef Documentation

template<class CompletionToken, class Signature>
using boost::beast::async_result< CompletionToken, Signature >::completion_handler_type = typename boost::asio::handler_type< CompletionToken, Signature>::type

The concrete completion handler type for the specific signature.

template<class CompletionToken, class Signature>
using boost::beast::async_result< CompletionToken, Signature >::return_type = typename boost::asio::async_result< completion_handler_type>::type

The return type of the initiating function.

Constructor & Destructor Documentation

template<class CompletionToken, class Signature>
boost::beast::async_result< CompletionToken, Signature >::async_result ( completion_handler_type h)
inlineexplicit

Construct an async result from a given handler.

When using a specalised async_result, the constructor has an opportunity to initialise some state associated with the completion handler, which is then returned from the initiating function.

Member Function Documentation

template<class CompletionToken, class Signature>
return_type boost::beast::async_result< CompletionToken, Signature >::get ( )
inline

Obtain the value to be returned from the initiating function.


The documentation for this class was generated from the following file: