Relative Content

Tag Archive for c++boostboost-asioc++-coroutine

prevent initial suspend of boost awaitable

I have a function that returns a boost::asio::awaitable that takes a large message object as argument to write a serialized string to a socket. Recently I was reading that a coroutine function will always suspend on entry and has the potential to create dangling references. I also read that you can prevent it from suspending which the author called a hot start. Is there a way to make boost::asio::awaitable not suspend initially so I can pass by reference safely before the first co_await?

ASIO: co_await callable to be run on a strand

The Problem We have some shared resource: a memory pool, thread-unsafe API, take your pick. We would like to control access to said resource via an ASIO strand. All routines accessing the resource should run on that strand. We’re also using C++20 coroutines and enjoy the illusion of sequential execution they provide. When accessing the […]