lewissbaker.github.io icon indicating copy to clipboard operation
lewissbaker.github.io copied to clipboard

Discussion for Understanding Symmetric Transfer

Open lewissbaker opened this issue 4 years ago • 4 comments

Comments and questions welcome on the post C++ Coroutines: Understanding Symmetric Transfer

lewissbaker avatar May 12 '20 19:05 lewissbaker

See also discussion thread on /r/cpp

lewissbaker avatar May 13 '20 02:05 lewissbaker

Thank you for this very interesting post. I'm using the cppcoro library and have the problem that I get a stack-overflow even though I use symmetric transfer. I created a minimal reproducible example and posted a question on stack-overflow: Symmetric transfer does not prevent stack-overflow for C++20 coroutines. I you have time could you please take a look at this question. Thank you very much in advance.

L-v-M avatar May 08 '21 10:05 L-v-M

This post is extremely good, talking this complicated topic in great detail. Helping guys who do not familiar with the detail of coroutine likes me a lot!

I have a question is that in the section of "Visualising the stack" (i.e. after changing to use symmetric transfer), I think the stack frames of coroutine_handle::resume() still keep accumulating while the stack frame of coroutine body or $resume will be popped properly. Because every time doing the symmetric transfer, there is a function call to returned_handle_from_await_suspend.resume() which won't be popped when symmetric transferring.

Or if the stack frame of .resume() and the $resume is actually the same one ? You just split them in the visualization for clarity.

huang-jl avatar Feb 15 '23 07:02 huang-jl

After reading the next post of understanding the compiler transform, I find the answer to my question. The compiler may not actually call the resume() on the returned_handle_from_await_suspend, it can use the "trampoline loop" and could avoid the accumulation of .resume() stack frame.

huang-jl avatar Feb 17 '23 06:02 huang-jl