Theory and Practice of Coroutines with Snapshots
While event-driven programming is a widespread model for asynchronous computing, its inherent control flow fragmentation makes event-driven programs notoriously difficult to understand and maintain. Coroutines are a general control flow construct that can eliminate control flow fragmentation. However, coroutines are still missing in many popular languages. This gap is partly caused by the difficulties of supporting suspendable computations in the language runtime.
We introduce first-class, type-safe, stackful coroutines with snapshots, which unify many variants of suspendable computing. Our design relies solely on the static metaprogramming support of the host language, without modifying the language implementation or the runtime. We also develop a formal model for type-safe, stackful and delimited coroutines, and we prove the respective safety properties. We show that the model is sufficiently general to express iterators, single-assignment variables, async-await, actors and event streams without inversion of control, backtracking, symmetric coroutines and continuations. Performance evaluations reveal that the proposed metaprogramming-based approach has a decent performance, with workload-dependent overheads of 1.03-2.11x compared to equivalent manually written code, and improvements of up to 6x compared to other approaches.
Thu 19 Jul
|11:00 - 11:25|
Ragnar MogkTechnische Universität Darmstadt, Lars BaumgärtnerPhilipps-Universität Marburg, Guido SalvaneschiTU Darmstadt, Bernd FreislebenPhilipps-Universität Marburg, Mira MeziniTU DarmstadtDOI
|11:25 - 11:50|
Hiroaki InoueMitsubishi Electric Corporation, Japan, Tomoyuki AotaniTokyo Institute of Technology, Atsushi IgarashiKyoto University, JapanDOI
|11:50 - 12:15|
|12:15 - 12:40|
Gian NtzikImperial College London, Pedro da Rocha PintoImperial College London, Julian SutherlandImperial College London, Philippa GardnerImperial College LondonDOI