#include <boost/asio/defer.hpp>
#include <boost/asio/dispatch.hpp>
#include <boost/asio/executor_work_guard.hpp>
+#include <boost/asio/recycling_allocator.hpp>
#include <boost/asio/post.hpp>
#include "bind_handler.h"
Handler handler;
// use Handler's associated allocator
- using Alloc2 = boost::asio::associated_allocator_t<Handler>;
+ using DefaultAlloc = boost::asio::recycling_allocator<void>;
+ using Alloc2 = boost::asio::associated_allocator_t<Handler, DefaultAlloc>;
using Traits2 = std::allocator_traits<Alloc2>;
using RebindAlloc2 = typename Traits2::template rebind_alloc<CompletionImpl>;
using RebindTraits2 = std::allocator_traits<RebindAlloc2>;
void destroy_defer(std::tuple<Args...>&& args) override {
auto w = std::move(work);
auto ex2 = w.second.get_executor();
- RebindAlloc2 alloc2 = boost::asio::get_associated_allocator(handler);
+ RebindAlloc2 alloc2 = boost::asio::get_associated_allocator(handler, DefaultAlloc{});
auto f = bind_and_forward(ex2, std::move(handler), std::move(args));
RebindTraits2::destroy(alloc2, this);
RebindTraits2::deallocate(alloc2, this, 1);
void destroy_dispatch(std::tuple<Args...>&& args) override {
auto w = std::move(work);
auto ex2 = w.second.get_executor();
- RebindAlloc2 alloc2 = boost::asio::get_associated_allocator(handler);
+ RebindAlloc2 alloc2 = boost::asio::get_associated_allocator(handler, DefaultAlloc{});
auto f = bind_and_forward(ex2, std::move(handler), std::move(args));
RebindTraits2::destroy(alloc2, this);
RebindTraits2::deallocate(alloc2, this, 1);
void destroy_post(std::tuple<Args...>&& args) override {
auto w = std::move(work);
auto ex2 = w.second.get_executor();
- RebindAlloc2 alloc2 = boost::asio::get_associated_allocator(handler);
+ RebindAlloc2 alloc2 = boost::asio::get_associated_allocator(handler, DefaultAlloc{});
auto f = bind_and_forward(ex2, std::move(handler), std::move(args));
RebindTraits2::destroy(alloc2, this);
RebindTraits2::deallocate(alloc2, this, 1);
boost::asio::post(std::move(f));
}
void destroy() override {
- RebindAlloc2 alloc2 = boost::asio::get_associated_allocator(handler);
+ RebindAlloc2 alloc2 = boost::asio::get_associated_allocator(handler, DefaultAlloc{});
RebindTraits2::destroy(alloc2, this);
RebindTraits2::deallocate(alloc2, this, 1);
}
public:
template <typename ...TArgs>
static auto create(const Executor1& ex, Handler&& handler, TArgs&& ...args) {
- auto alloc2 = boost::asio::get_associated_allocator(handler);
+ auto alloc2 = boost::asio::get_associated_allocator(handler, DefaultAlloc{});
using Ptr = std::unique_ptr<CompletionImpl>;
return Ptr{new (alloc2) CompletionImpl(ex, std::move(handler),
std::forward<TArgs>(args)...)};