Boost logo

Boost Users :

Subject: [Boost-users] [Asio/Beast] Any non-obvious reasons for no bind_executor_and_allocator?
From: Sorin Fetche (sorin.fetche_at_[hidden])
Date: 2018-12-20 00:30:53


Hi,

As I'm looking to modernize an older C++03 project based on Boost.Asio to
use C++17 and the net TS api, I am not ready yet to give up on using
lambdas for completion handlers.

Boost.Asio and Boost.Beast have some utilities for correctly implementing
asynchronous composed operations but from them only asio::bind_executor
seems to be applicable to lambdas. And the problem is that it only
associates an executor with a (lambda) object; I didn't find any utility
for associating an allocator too.

Could there be any reason for a utility that associates both an executor
and an allocator with an object to not work correctly when implementing
asynchronous operations? Or is it just that this utility has not been
implemented yet?

I did come across the paper "Networking TS Associations for Call
Wrappers"[1], but I didn't see any mention there about bind_executor or
something similar for allocators or why this kind of approach wouldn't work.

I would be very happy if I could write something like:

asio::post(
    socket_.get_executor(),
    bind_executor_and_allocator_from(
        handler_,
        [...] { self_.handler_(...); }));

and, unless I'm missing something, such a utility could be implemented
similarly to the existing asio::bind_executor.

Thank you,
Sorin

[1] http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p1133r0.html



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net