C++ Coroutine Intuition - Roi Barkan - CppNow 2023

Поділитися
Вставка
  • Опубліковано 18 гру 2024

КОМЕНТАРІ • 12

  • @User-cv4ee
    @User-cv4ee 3 місяці тому

    @17:35 Can function D suspend coroutine C and return the handle to function B and resume from there? What happens to the stub for C, which is squeezed between D and B on the stack, when we are in function B then?

    • @Roibarkan
      @Roibarkan 3 місяці тому

      With stackless coroutines (what we have in C++20) it's not possible for a "regular function" (such as D in this slide) to cause suspension (run co_await or co_yield), for exactly the reason you describe - there's no room to hold its state. Only a coroutine can get suspended and thus the top of the stack is a 'coroutine stub'

    • @User-cv4ee
      @User-cv4ee 3 місяці тому

      @@Roibarkan How about D calls "C_return_type".wait() (assume `wait` is the API exposed by C's return type that just suspends forever) and moves it through a normal return to B?

  • @Roibarkan
    @Roibarkan Рік тому +3

    20:30 the image in slide 13 was taken/borrowed from an awesome talk by Kevlin Henney. ua-cam.com/video/s2zELGvNlbA/v-deo.htmlh4m12s

    • @KX36
      @KX36 6 місяців тому

      Thanks. I tried to find this from the info in the video but couldn't.
      I was hoping Kevlin had some different angle on coroutines that would make them more understandable but unfortunately not in that talk.

  • @Roibarkan
    @Roibarkan Рік тому +4

    54:12 Excuse the English - I guess ‘aspirational’ is a better phrasing than ‘inspirational’

    • @randall172
      @randall172 Рік тому

      would python's asyncio be a good start pointt for gaining an intuition on coroutines?

    • @Roibarkan
      @Roibarkan Рік тому

      I’m not an expert on python. My brief understanding is that python asyncio is somewhat more high-level than c++ coroutines, and thus python coroutines are probably easier to work with, but potentially less flexible. If one is accustomed to python coroutines- they can be sure that the same model can be done in c++ (and I would look at the asio library and cppcoro as starting points). I do not think that python asyncio supports symmetric transfer, for example, but I’m not sure. Thanks for the question

  • @brynyard
    @brynyard Рік тому +4

    Very good overview of coroutines, but a lot of the questions underway should've been suspended as the answer was just a couple of slides down the line, and yet others was on a completely different tangent/world/fantasy concept, and as such just big distraction from the otherwise well structured talk.

    • @KX36
      @KX36 6 місяців тому

      I think the middle of the talk would be great separated out and slowed down into an intermediate level talk for people who already know the structure and basic use of coroutines and std::generator. The live audience of this talk seemed to require a more introductory talk first.