Asio Extensions
Additional functionality built on top of (Boost.)Asio
asioext::composed_operation< Handler > Class Template Reference

Base class for composed operations. More...

#include <asioext/composed_operation.hpp>

+ Inheritance diagram for asioext::composed_operation< Handler >:

Public Member Functions

 composed_operation (Handler &&handler)
 

Public Attributes

Handler handler_
 

Detailed Description

template<typename Handler>
class asioext::composed_operation< Handler >

Base class for composed operations.

This class template is intended to be used as a base class for custom composed operation types that wrap a user-provided handler. As such, it expects child classes to implement operator().

It wraps the given handler object and provides overloads for asio's hooks that forward to the real handler's hooks (if implemented).

For a detailed description of composed operations, see [async.reqmts.async.composed] inside the Networking TS.

Implemented hooks:

  • asio_handler_allocate()
  • asio_handler_deallocate()
  • asio_handler_is_continuation()
  • asio_handler_invoke()

This class does not provide support for asio::associated_allocator<> and asio::associated_executor<> (Asio 1.11.0+). The user is required to manually specialize these templates in the asio namespace.

Example specializations:

namespace asio {
template <typename Handler, typename Allocator>
struct associated_allocator<myns::my_operation<Handler>, Allocator>
{
static type get(const myns::my_operation<Handler>& h,
const Allocator& a = Allocator()) ASIOEXT_NOEXCEPT
{
}
};
template <typename Handler, typename Executor>
struct associated_executor<myns::my_operation<Handler>, Executor>
{
typedef typename associated_executor<Handler, Executor>::type type;
static type get(const myns::my_operation<Handler>& h,
const Executor& ex = Executor()) ASIOEXT_NOEXCEPT
{
return associated_executor<Handler, Executor>::get(h.handler_, ex);
}
};
}
Note
This type's operator() is executed by the user-specified executor / invocation hook (see above). It is not suitable for operations that are to be executed in a service-provided context (e.g. a private io_service).

Constructor & Destructor Documentation

◆ composed_operation()

template<typename Handler>
asioext::composed_operation< Handler >::composed_operation ( Handler &&  handler)
inline

Member Data Documentation

◆ handler_

template<typename Handler>
Handler asioext::composed_operation< Handler >::handler_