Skip to content

(WIP) Use AsioFuture to wait asynchronously on blocking tasks#10626

Draft
jschmidt-icinga wants to merge 2 commits intomasterfrom
asio-future-for-non-blocking-handlers
Draft

(WIP) Use AsioFuture to wait asynchronously on blocking tasks#10626
jschmidt-icinga wants to merge 2 commits intomasterfrom
asio-future-for-non-blocking-handlers

Conversation

@jschmidt-icinga
Copy link
Contributor

@jschmidt-icinga jschmidt-icinga commented Nov 7, 2025

This could be an alternative approach to get rid of the CpuBoundWork.

WIP for now, but discussions are welcome.

Blockers

  • async_initiate was only added in boost-1.70
  • The deduction of an async operation's return type was only added in boost-1.80 This is actually only necessary for elegance, to support arbitrary completion handlers like ASIO does. Instead we could just (for now) add overloads for the completion handlers we need (i.e. callbacks and yield_context) and ignore others. As long as we're on these old boost versions nobody is going to implement any other completion handlers anyway.
  • There's a crashing bug in the coroutines' completion handler with handler-signatures including std::exception_ptr even in the current version. I will report this to boost.asio, but on its own this wouldn't be too difficult to work around. (However, this only affects the functionality in point 2, so the poor-man's version described in the last bullet point would be unaffected)

@cla-bot cla-bot bot added the cla/signed label Nov 7, 2025
@jschmidt-icinga jschmidt-icinga force-pushed the asio-future-for-non-blocking-handlers branch 3 times, most recently from 6ec7bae to 86ff3fc Compare November 7, 2025 10:33
@jschmidt-icinga jschmidt-icinga force-pushed the asio-future-for-non-blocking-handlers branch from 86ff3fc to 5879e6f Compare November 7, 2025 10:38
else if (request.method() == http::verb::delete_)
HandleDelete(request, response);
else
return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about wrapping at the Handle*() level? I mean, what a waste to deploy a callback which will almost immediately return false..

Copy link
Contributor Author

@jschmidt-icinga jschmidt-icinga Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely. That's why I put an extra (WIP) in front of the second commit. It was just thrown together quickly to test if it even works. I'm sure it can be made a lot nicer by applying the callbacks more selectively.

Copy link
Member

@Al2Klimov Al2Klimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally came here to write:

Maybe you can replace #10273

But I've seen your updated OP.

My strong opinion

I'm clearly against new Boost packages, unless we AbSoLuTeLy NeEd them!

@jschmidt-icinga
Copy link
Contributor Author

I'm clearly against new Boost packages, unless we AbSoLuTeLy NeEd them!

I fully agree with you here. I won't argue for shipping boost packages on targets where we don't already need them anyway.

The PR description is just to track which versions would be needed.

@jschmidt-icinga jschmidt-icinga added the stalled Blocked or not relevant yet label Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla/signed stalled Blocked or not relevant yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants