# [C++ links](https://github.com/MattPD/cpplinks): Coroutines https://github.com/MattPD/cpplinks / C++ Standard / C++20 / Coroutines _(draft; work in progress)_ \#coroutines ([C++ Slack](https://cppalliance.org/slack/)): https://cpplang.slack.com/archives/C5JS5JXT5 # Readings - https://en.cppreference.com/w/cpp/language/coroutines - Working Draft, C++ Coroutines - https://wg21.link/n4775 - merged into C++20, http://wg21.link/p0912 - Brain Unrolling: Generators and the Sweet Syntactic Sugar of Coroutines - http://videocortex.io/2019/Brain-Unrolling/ - Coroutines TS Customization Points - https://hackmd.io/s/S1H_loeA7 - Dawid Pilarski - Coroutines introduction - https://blog.panicsoftware.com/coroutines-introduction/ - Your first coroutine - https://blog.panicsoftware.com/your-first-coroutine/ - co_awaiting coroutines - https://blog.panicsoftware.com/co_awaiting-coroutines/ - How C++ coroutines work - Kirit Sælensminde - https://kirit.com/How%20C%2B%2B%20coroutines%20work - Lewis Baker - C++ Coroutines: - Coroutine Theory - https://lewissbaker.github.io/2017/09/25/coroutine-theory - Understanding operator co_await - https://lewissbaker.github.io/2017/11/17/understanding-operator-co-await - Understanding the promise type - https://lewissbaker.github.io/2018/09/05/understanding-the-promise-type - Understanding Symmetric Transfer - https://lewissbaker.github.io/2020/05/11/understanding_symmetric_transfer - Rainer Grimm - ModernesCpp.com - https://www.modernescpp.com/index.php/tag/coroutines - Raymond Chen - C++ coroutines - Getting started with awaitable objects - https://devblogs.microsoft.com/oldnewthing/20191209-00/?p=103195 - Constructible awaitable or function returning awaitable? - https://devblogs.microsoft.com/oldnewthing/20191210-00/?p=103197 - Framework interop - https://devblogs.microsoft.com/oldnewthing/20191211-00/?p=103201 - Awaiting an IAsyncAction without preserving thread context - https://devblogs.microsoft.com/oldnewthing/20191212-00/?p=103207 - Short-circuiting suspension - part 1 - https://devblogs.microsoft.com/oldnewthing/20191213-00/?p=103210 - part 2 - https://devblogs.microsoft.com/oldnewthing/20191216-00/?p=103217 - no callable ‘await_resume’ function found for type - https://devblogs.microsoft.com/oldnewthing/20191217-00/?p=103219 - Defining the `co_await` operator - https://devblogs.microsoft.com/oldnewthing/20191218-00/?p=103221 - The `co_await` operator and the function search algorithm - https://devblogs.microsoft.com/oldnewthing/20191219-00/?p=103230 - The problem of the synchronous apartment-changing callback - https://devblogs.microsoft.com/oldnewthing/20191220-00/?p=103232 - The problem of the DispatcherQueue task that runs too soon - part 1 - https://devblogs.microsoft.com/oldnewthing/20191223-00/?p=103255 - part 2 - https://devblogs.microsoft.com/oldnewthing/20191224-00/?p=103262 - part 3 - https://devblogs.microsoft.com/oldnewthing/20191225-00/?p=103265 - part 4 - https://devblogs.microsoft.com/oldnewthing/20191226-00/?p=103268 - What are coroutines and why should I care? - Marco Alesiani - http://www.italiancpp.org/2016/11/02/coroutines-internals/ - GCC implementation - https://gcc.gnu.org/wiki/cxx-coroutines - Initial implementation pushed to master. - https://gcc.gnu.org/ml/gcc-patches/2020-01/msg01096.html - LLVM implementation - Coroutines in LLVM - https://llvm.org/docs/Coroutines.html ## Research ### 2019 - Bridging the Latency Gap between NVM and DRAM for Latency-bound Operations - interleaving task execution with C++20 coroutines to hide memory access latency - Data Management on New Hardware (DaMoN) 2019 - Georgios Psaropoulos, Ismail Oukid, Thomas Legler, Norman May, Anastasia Ailamaki - https://dl.acm.org/citation.cfm?id=3329917 - Don’t stall – multitask! Random access to main memory with cache-like performance - https://www.linkedin.com/pulse/dont-stall-multitask-georgios-psaropoulos/ ### 2018 - Exploiting Coroutines to Attack the "Killer Nanoseconds" - PVLDB 11, 11 (July 2018) - Christopher Jonathan, Umar Farooq Minhas, James Hunter, Justin Levandoski, Gor Nishanov - http://www.vldb.org/pvldb/vol11/p1702-jonathan.pdf ### 2017 - Interleaving with Coroutines: A Practical Approach for Robust Index Joins - PVLDB 11, 2 (October 2017) - Georgios Psaropoulos, Thomas Legler, Norman May, and Anastasia Ailamaki - http://www.vldb.org/pvldb/vol11/p230-psaropoulos.pdf # Software - CppCoro - A coroutine library for C++ - https://github.com/lewissbaker/cppcoro - Conduit: Lazy High Performance Streams using Coroutine TS - https://github.com/loopperfect/conduit - folly::coro - a developer-friendly asynchronous C++ framework based on Coroutines TS - https://github.com/facebook/folly/tree/master/folly/experimental/coro - https://cppcast.com/2019/03/kirk-shoop/ ## Examples - libc++ - https://github.com/llvm/llvm-project/blob/release/8.x/libcxx/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp - https://github.com/llvm/llvm-project/blob/release/8.x/libcxx/test/support/coroutine_types.h - http://cppcast.com/2017/07/gor-nishanov/ - Compiler Explorer: Coroutines clang demo - https://godbolt.org/g/pq6x57 - Wandbox: Coroutines with Ranges - https://wandbox.org/permlink/D60wIndMZbth7BXS - David Hollman - https://twitter.com/TheWholeDavid/status/1063135275671535616 - https://wandbox.org/permlink/OqlSdKihqjBX2qUs - Boost.Asio - https://www.boost.org/doc/libs/release/doc/html/boost_asio/examples/cpp17_examples.html - coro-async - C++ coroutine based networking library (WIP) - https://github.com/arun11299/coro-async - Coroutine TS: A new way of thinking - https://github.com/arBmind/2018-cogen-en - https://github.com/arBmind/2018-cogen-en/tree/develop/code - Exploring the C++ Coroutine - https://github.com/luncliff/coroutine/ - https://github.com/luncliff/coroutine/wiki - coro: Single-header library facilities for C++2a Coroutines - https://github.com/Quuxplusone/coro - https://quuxplusone.github.io/blog/2019/07/03/announcing-coro-examples/ # Talks ## 2019 - code::dive 2019 - C++20 Coroutines: Introduction - Marcin Grzebieluch - https://www.youtube.com/watch?v=vDA925C55F0 - https://codedive.pl/index/speaker/name/marcin-grzebieluch - code::dive 2019 - C++20 Coroutines: Asynchronity reimagined - Miłosz Warzecha - https://www.youtube.com/watch?v=FeUOKwLLQe0 - https://codedive.pl/index/speaker/name/milosz-warzecha - code::dive 2019 - C++20 Coroutines: What's next? - Dawid Pilarski - https://www.youtube.com/watch?v=vNL9UFnyQJU - https://codedive.pl/index/speaker/name/dawid-pilarski - Exploring C++20 Coroutines - C/C++ Dublin User Group 2019; Justin Durkan - https://www.youtube.com/watch?v=RhXaKOe3JZM - https://drive.google.com/file/d/1sHtERPE4tgn2R4QeAAN-TlSD_gd9CE3d/view - Structured Concurrency: Writing Safer Concurrent Code with Coroutines and Algorithms - CppCon 2019; Lewis Baker - https://www.youtube.com/watch?v=1Wy5sq3s2rg - 2019 GNU Tools Cauldron: Iain Sandoe - C++20 Coroutines in GCC - https://gcc.gnu.org/wiki/cauldron2019#cauldron2019talks.c_coroutines_function_and_implementation_in_GCC - https://gcc.gnu.org/wiki/cauldron2019talks?action=AttachFile&do=view&target=Coroutine-Cauldron-2019.pdf - https://www.youtube.com/watch?v=5NybFJ6O7T0&list=PL_GiHdX17Wtx2Bu1O_bREetZZv4moIaRi&index=5 - 2019 Adi Shavit - Generators, Coroutines and Other Brain Unrolling Sweetness - NDC TechTown: https://www.youtube.com/watch?v=CwCJBpB7Z5w - CppCon: https://www.youtube.com/watch?v=qYHDERleSL8 - CoreHard Autumn: https://www.youtube.com/watch?v=qjQBAgsj9CI - code::dive 2019 - https://www.youtube.com/watch?v=ahorllPz5rE - https://codedive.pl/index/speaker/name/adi-shavit - 2019 Core C++: Yehezkel Bernat - Coroutines - the future of future (and more) - https://www.youtube.com/watch?v=1tQfcPnHeRY - https://github.com/YehezkelShB/CoreCpp2019-Coroutines - 2019 C++ Korea Facebook Group: Park Dong Ha - Exploring the C++ Coroutine: Approach, Compiler, and Issues - https://github.com/luncliff/coroutine/wiki/Exploring-the-Cpp-Coroutine ## 2018 - 2018 Meeting C++: Andreas Reischuck - Coroutine TS a new way of thinking - https://www.youtube.com/watch?v=RL5oYUl5548 - https://github.com/arBmind/2018-cogen-en - 2018 CppCon: G. Nishanov “Nano-coroutines to the Rescue! (Using Coroutines TS, of Course)” - https://www.youtube.com/watch?v=j9tlJAqMV7U - 2018 LLVM Developers’ Meeting: J. McCall “Coroutine Representations and ABIs in LLVM” - https://www.youtube.com/watch?v=wyAbV8AM9PM - 2018 Core C++: Yehezkel Bernat - Coroutines - Back to the Future - (Hebrew) https://www.youtube.com/watch?v=eZrhz9v1ApE - (English) https://corecppil.github.io/Meetups/2018-09-17_Sweet-C++/Coroutines.pdf ## 2017 - 2017 CppCon: Anthony Williams “Concurrency, Parallelism and Coroutines” - https://www.youtube.com/watch?v=JvHZ_OECOFU - 2017 CppCon: Gor Nishanov “Naked coroutines live (with networking)” - https://www.youtube.com/watch?v=UL3TtTgt3oU - 2017 CppCon: Toby Allsopp “Coroutines: what can't they do?” - https://www.youtube.com/watch?v=mlP1MKP8d_Q - 2017 Pacific++: Toby Allsopp "An Introduction to the Proposed Coroutine Support for C++" - https://www.youtube.com/watch?v=nWuXubffryo ## 2016 - 2016 await/yield: C++ coroutines - Zbigniew Skowron - 30 November, 2016 - http://cpp.mimuw.edu.pl/files/await-yield-c++-coroutines.pdf - 2016 CppCon: Gor Nishanov “C++ Coroutines: Under the covers" - https://www.youtube.com/watch?v=8C8NnE1Dg4A - 2016 CppCon: James McNellis “Introduction to C++ Coroutines" - https://www.youtube.com/watch?v=ZTqHjjm86Bw - 2016 LLVM Developers’ Meeting: G. Nishanov “LLVM Coroutines” - https://www.youtube.com/watch?v=Ztr8QvMhqmQ ## 2015 - 2015 C++Now - Gor Nishanov: C++17 coroutines for app and library developers - https://www.youtube.com/watch?v=proxLbvHGEQ - 2015 CppCon: Gor Nishanov “C++ Coroutines - a negative overhead abstraction" - https://www.youtube.com/watch?v=_fu0gx-xseY - 2015 Meeting C++: An Introduction to C++ Coroutines - James McNellis - https://www.youtube.com/watch?v=YYtzQ355_Co