This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
So I have a coroutine I've spawned via asio::spawn that's handling an HTTP connection.
I have a shared object with a bunch of variables that I want to use from various HTTP handlers. To that end, I have a strand to serialize access to these variables.
I know I can asio::spawn(<strand>, <handler>) initially, but I don't want to hog the strand for the whole HTTP connection.
Is there a way I can suspend/awaken my coroutine inside a strand, and then suspense/awaken back outside when I'm done?
Initially I was just using asio::spawn(<strand>, <handler>) to execute operations on my shared object because I don't strictly need to wait for things to finish, but I'm anticipating issues where coroutines pile up and cause resource exhaustion. In other words, I'm trying to implement some back pressure (HTTP requests don't complete until the operation is complete).
Any ideas? This seems like it should be really easy. I remember using async/await in C# and "teleporting" between different contexts (e.g. getting onto the main thread then back into a worker pool) was fairly trivial.
Subreddit
Post Details
- Posted
- 4 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/cpp_questio...