c++asynchronousc++26

How is the new asynchronous model in C++26 different from existing models?


I've been reading parts of https://eel.is/c++draft/exec and other related articles regarding this topic. I know what schedulers, receivers, and senders are. However, I don't see how these interactions create such a new model for asynchronous programming in C++.

I'm curious how they differ from other models such as primitive std::future and std::promise, executors, and Boost's ASIO?


Solution

  • I'm curious how they differ from other models such as primitive std::future and std::promise, executors, and Boost's ASIO?

    Not sure what you mean by "executors" if not the very proposal you refer to, nor I know about Boost ASIO, but in regards to how P2300 (the proposal at the basis of that part of the draft you refer to) relates to std::future and std::promise, the difference is precisely that those two are very low level building blocks of what Eric Niebler calls "unstructured concurrency". With those building blocks, a lot of responsibility falls on you, as a programmer, in terms of managing lifetimes (say of states, callbacks, ...).

    P2300 is the basis of structured concurrency, which aims to provide building blocks that free you from (some of?) those responsiblities. To clarify, there's an analogy that Eric Niebler draws between

    This is a very broad topic, however, and I am honestly not able to answer thoroughly to the questions (if I could, I'd be probably be concerned more about how can I spend my 500k£ a year than spending time here), but I think you can find most of the answer to your question in these 3 talks (and at the links above):

    Eric Niebler (and in the first video Daisy Hollman) will cover enough fo the topic. Too much to put in an answer here, though. Plus it's not that I've understood every single bit of it :D