C++ futures part 1: The mental model

(devblogs.microsoft.com)

25 points | by ibobev 1 day ago

2 comments

  • ahartmetz 1 hour ago
    This seems to omit the main point of it, though? That the compiler turns a function into a state machine that can restart from any of its suspension points. I guess that's the "state" variable, but what I'm talking about is what it contains and the partially compiler-generated code that deals with it.

    C++ async is unfortunately a "bring your own runtime" sort of model (for now), but it does handle the part that would be incredibly tedious by hand, building above mentioned state machine.

    • jcranmer 51 minutes ago
      That's the co_await/co_yield/co_routine stuff, which this isn't talking about--this is talking about the std::future-et-al logic, which predates C++ coroutines by almost a decade.
    • kccqzy 47 minutes ago
      You are confusing it with coroutines. This is just a plain library feature that the compiler doesn’t necessarily have special support for.
  • thefourthchime 24 minutes ago
    Wow, I had no idea Raymond Chen was still doing blog posts. I used to love his posts back in the day.
    • afdbcreid 19 minutes ago
      He writes regularly. Sometimes explaining C++, rarely explaining C#, sometimes historic stories, sometimes current stories, etc..