CppCon 2014: Gor Nishanov "await 2.0: Stackless Resumable Functions"

CppCon · 12K views · 2014 · 53:42

Open on YouTube

C, C++, Rust, Go & systems languagesProgramming language designtalkdated

Why Stack Overflow recommends it

Stack Overflow users link it as the original design talk for C++ coroutines, both for specific techniques like parent-stealing scheduling and as a starting point for learning how coroutines relate to async libraries like Asio.

Recommended by 1 people across 1 different months, 2014 to 2022.

What it is

A CppCon 2014 talk by Gor Nishanov of Microsoft's C++ team on the proposed 'await' feature, stackless resumable functions that became C++ coroutines. He walks through tasks, generators and goroutine-style examples, how the compiler machinery works, and how library authors can plug in their own coroutine types.

What people said

Recommends Massimiliano · 2014-12 · Stack Overflow · on “Moving execution from one thread to another to implement task parallelism and call-by-future”

I think you might have a chance with the resumable functions currently proposed for C++ standartization [LINK] . The proposal is not approved yet, but Visual Studio 15 CTP implements the proposal, so you can try making a prototype (if you can use MSVC compiler). Gor Nishanov (one of the authors of the latest proposal paper) describes a very similar example of calculating Fibonacci with "parent-stealing scheduling" starting at 23:47 in his CppCon talk: [this video] Note, however, that I couldn't find any sources/samples of the implementation of the spawnable<T> , so you may need to contact the proposal authors for details.

Cites David Ledger · 2019-07 · Stack Overflow · on “Are stackless C++20 coroutines a problem?”

Based on the following it looks like coroutines in C++20 will be stackless. [LINK] I'm concerned for many reasons: On embedded systems heap allocation is often not acceptable. When in low level code, nesting of co_await would be useful (I don't believe stackless co-routines allow this). With a stackless coroutine, only the top-level routine may be suspended. Any routine called by that top-level routine may not itself suspend. This prohibits providing suspend/resume operations in routines within a general-purpose library. [LINK] More verbose code because of the need for custom allocators and memory pooling. Slower if the task waits for the operating system to allocate it some memory (without

Cites Mark Wallace · 2022-07 · Stack Overflow · on “What is the relationship between Boost::Asio and C++20 coroutines?”

I started trying to learn Boost::Asio by reading the documentation and example code [LINK] . I found things difficult to understand, particularly because the model seemed similar to coroutines. I then decided to learn about coroutines, starting with this cppcon talk [this video] . In the linked talk, the following line was given in an example of coroutine usage. The example was written in 2014, so the syntax may not match C++20 coroutines. auto conn = await Tcp::connect.Read("127.0.0.1", 1337) This feels similar to the stated goals of Boost::Asio. However, in the examples section of the Boost::Asio documentation, there is an example [LINK] that mixes Boost::Asio and C++20 coroutines. (I do not ye