Coroutines and C++ DSLs for Human Scale Concurrency

By Dominic Robinson

C++ coroutines have not yet been standardised, but are available today in Visual Studio 2015 (coming soon to clang/llvm) in the form of the stackless coroutines/resumable functions [1] presented at CppCon2016 [2][3][4].

This session will look beyond the canonical examples of generators and asynchronous IO to see if coroutines can be leveraged in the pursuit of C++ DSLs to make concurrency easier to work with for humans - "Concurrency at Human Scale".

As of writing, the investigations and technology behind this talk are still evolving, so the outcome is not a foregone conclusion.

Other material, illustrating the search for inspiration on how to tackle these problems, may include:

A look at other systems for specifying, testing and reasoning about concurrency such as Leslie Lamport’s PlusCal/TLA+ [5] (see also [6]).

A look at the facilities for high level control flow manipulation afforded by other languages and runtime systems such as Racket’s first class continuations, continuation marks and prompts [7][8].

A look at other programming models for concurrency including Erlang’s actors (in the form of C++ Erlesque Actors [9]), Linda’s tuple spaces [10], and Syndicate’s coordinated concurrent proramming [11].

Level: Intermediate to expert

References:

[1] Gor Nishanov, Jim Radigan : Resumable Functions - N4402 https://isocpp.org/files/papers/N4402.pdf

[2] CppCon 2016: Jame McNellis - Introduction to C++ Coroutines https://www.youtube.com/watch?v=ZTqHjjm86Bw&list=PLHTh1InhhwT7J5jl4vAhO1WvGHUUFgUQH&index=41

[3] CppCon 2016: Kenny Kerr & James McNellis “Embracing Standard C++ for the Windows Runtime" https://www.youtube.com/watch?v=v0SjumbIips&index=61&list=PLHTh1InhhwT7J5jl4vAhO1WvGHUUFgUQH

[4] CppCon 2016: Gor Nishanov “C++ Coroutines: Under the covers" https://www.youtube.com/watch?v=8C8NnE1Dg4A&index=87&list=PLHTh1InhhwT7J5jl4vAhO1WvGHUUFgUQH

[5] Leslie Lamport: The PlusCal Algorithm Language http://research.microsoft.com/en-us/um/people/lamport/tla/pluscal/

[6] ACCU 2016: Dominic Robinson : Test Driven Specification – A Gentle Introduction to TLA+ (finding concurrency bugs before you write code) https://accu.org/index.php/conferences/accu_conference_2016/accu2016_sessions#Test_Driven_Specification_%E2%80%93_A_Gentle_Introduction_to_TLA+_(finding_concurrency_bugs_before_you_write_code)

[7] Continuations in Racket https://docs.racket-lang.org/reference/cont/

[8] Mathew Flatt et al : Adding Delimited and Composable Control to a Production Programming Environment http://www.cs.utah.edu/plt/publications/icfp07-fyff.pdf

[10] Nichlas Carriero and David Gelernter : Linda in Context http://www.inf.ed.ac.uk/teaching/courses/ppls/linda.pdf