Boost logo

Boost Users :

From: Mohammad Nejati [ashtum] (ashtumashtum_at_[hidden])
Date: 2024-04-09 14:33:35


> I'm trying to write a simple ASIO send/receiver that uses message queueing. The goal is to have a number of virtual streams over a single TCP connection. This is pretty simple using callbacks, but I can't figure out the coroutines alternative. Here is my simplified sample code. Note that I'm using asio::experimental::promise the same way I would use std::promise which obviously doesn't work, but it illustrates what I'm trying to do. What is the simplest solution to my problem?

Have you considered utilizing asio::experimental::basic_channel?
https://www.boost.org/doc/libs/1_84_0/doc/html/boost_asio/reference/experimental__basic_channel.html

By the way, there is no synchronization mechanism in Asio akin to a
future/promise pair, if you're open to external solutions, you might
want to explore these options:
https://github.com/ashtum/saf
https://github.com/ashtum/oneshot

Regards,
Mohammad


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