chriskohlhoff / asio

Asio C++ Library
http://think-async.com/Asio
4.73k stars 1.2k forks source link

Feature request: multi-shot equivalent of `any_completion_handler` #1330

Open ecorm opened 12 months ago

ecorm commented 12 months ago

It would be nice to have an equivalent of any_completion_handler where the handler can be invoked multiple times. A real-life use case is a user-registered RPC handler in a middleware library, where the user wants to specify an executor via which the RPC should be posted.

It would be preferable if such a multi-shot handler were copyable, the same way as std::function is copyable.

For now, I've hacked something that combines a std::function along with an any_completion_executor: https://github.com/ecorm/cppwamp/blob/ae2d929fef3703531343a71a4d8f41d15d916daa/cppwamp/include/cppwamp/anyhandler.hpp#L68