C++ Logo

std-proposals

Advanced search

[std-proposals] C++ Networking Feature Request: Type-Erased Handler Wrapper

From: Emile Cormier <emile.cormier.jr_at_[hidden]>
Date: Wed, 27 Jul 2022 14:40:12 -0300
(Cross-posted to https://github.com/chriskohlhoff/asio/issues/1100)

In the upcoming C++ networking proposal, we need a wrapper that type-erases
an asynchronous handler and bundles its associated executor and allocator.
This would prevent the forcing of higher-level networking libraries to be
header-only. It would also allow such higher-level networking libraries to
expose known types in its API, instead of templatized function arguments.

This proposed type-erased handler could be passed to asio::post and the
like. It would also have to support underlying handlers that are move-only.

Some of us still care about compile times and being able to apply the Pimpl
idiom. This is not possible when our libraries are forced to be header-only
because of Asio wanting everything to be a template.

I have found such a wrapper in the wild at
https://github.com/inetic/asio-utp/blob/master/include/asio_utp/detail/handler.hpp
. However it lacks small buffer optimization and has additional stuff that
seems specific to that library.

Cheers,
Emile Cormier

Received on 2022-07-27 17:40:24