License: Creative Commons Attribution 3.0 Unported license (CC BY 3.0)
When quoting this document, please refer to the following
DOI: 10.4230/LIPIcs.ECOOP.2018.3
URN: urn:nbn:de:0030-drops-92087
URL: http://dagstuhl.sunsite.rwth-aachen.de/volltexte/2018/9208/
Prokopec, Aleksandar ;
Liu, Fengyun
Theory and Practice of Coroutines with Snapshots
Abstract
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, event streams, 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.11 x compared to equivalent manually written code, and improvements of up to 6 x compared to other approaches.
BibTeX - Entry
@InProceedings{prokopec_et_al:LIPIcs:2018:9208,
author = {Aleksandar Prokopec and Fengyun Liu},
title = {{Theory and Practice of Coroutines with Snapshots}},
booktitle = {32nd European Conference on Object-Oriented Programming (ECOOP 2018)},
pages = {3:1--3:32},
series = {Leibniz International Proceedings in Informatics (LIPIcs)},
ISBN = {978-3-95977-079-8},
ISSN = {1868-8969},
year = {2018},
volume = {109},
editor = {Todd Millstein},
publisher = {Schloss Dagstuhl--Leibniz-Zentrum fuer Informatik},
address = {Dagstuhl, Germany},
URL = {http://drops.dagstuhl.de/opus/volltexte/2018/9208},
URN = {urn:nbn:de:0030-drops-92087},
doi = {10.4230/LIPIcs.ECOOP.2018.3},
annote = {Keywords: coroutines, continuations, coroutine snapshots, asynchronous programming, inversion of control, event-driven programming}
}
Keywords: |
|
coroutines, continuations, coroutine snapshots, asynchronous programming, inversion of control, event-driven programming |
Collection: |
|
32nd European Conference on Object-Oriented Programming (ECOOP 2018) |
Issue Date: |
|
2018 |
Date of publication: |
|
10.07.2018 |