On Composing Asynchronous Operations
Abstract
Asynchronous operations are very useful for actions that wait for an external event or work for a long time, to avoid blocking the thread that launches them. Unfortunately, whether they report their termination via callbacks or via completing a future, composing several asynchronous calls is difficult and error prone. The continuations mechanism (provided, for example, in C# Task Parallel Library via ContinueWith()) offers limited support for scheduling a sequence of operations. In this paper we try to improve this mechanism with better support for sequencing operations and exceptions, and with support for conditionals and loops, while covering the specifics of a C++ implementation. The most recent version of our
source code is at [14].
References
[2] Java Platform, Standard Edition 8 API Specification, CompletableFuture . https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CompletableFuture.html. Accessed: 2023.
[3] David Pine, e. a. Task parallel library (tpl). https://learn.microsoft.com/en-us/dotnet/standard/parallel-programming/task-parallel-library-tpl, 2022. Accessed: 2022.
[4] Duan, J., Yi, X., Wang, J., Wu, C., and Le, F. Netstar: A future/promise framework for asynchronous network functions. IEEE Journal on Selected Areas in Communications 37, 3 (2019), 600–612.
[5] Elizarov, R., Belyaev, M., Akhin, M., and Usmanov, I. Kotlin coroutines: Design and implementation. Onward! 2021, Association for Computing Machinery, p. 68–84.
[6] Gustafsson N., Laksberg A., S. H. M. S. A standardized representation of asynchronous operations, technical report n3538. https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3558.pdf, 2013. Accessed: 2022.
[7] Haller, P., and Miller, H. A reduction semantics for direct-style asynchronous observables. Journal of Logical and Algebraic Methods in Programming 105 (03 2019).
[8] Lab, A. S. T. stlab: Api documentation. futures. https://stlab.cc/libraries/concurrency/future/. Accessed: 2023.
[9] Lee Howes, Andrii Grynenko, J. F. Continuations without overcomplicating the future. https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0783r0.html, 2017. Accessed: 2022.
[10] Liskov, B., and Shrira, L. Promises: Linguistic support for efficient asynchronous procedure calls in distributed systems. In Proceedings of the ACM SIGPLAN 1988 Conference on Programming Language Design and Implementation (New York, NY, USA, 1988), PLDI ’88, Association for Computing Machinery, p. 260–267.
[11] Manolescu, D. A. Workflow enactment with continuation and future objects. 40–51.
[12] Marshall Cline, e. a. A unified futures proposal for c++. https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1054r0.html, 2018. Accessed: 2022.
[13] Meyers, S. Effective Modern C++: 42 Specific Ways to Improve Your Use of C++11 and C++14, 1st ed. O’Reilly Media, Inc., 2014.
[14] Radu, L. futures-demo https://github.com/rlupsa/futures-demo, 2023.
[15] Ranaldo, N., and Zimeo, E. Analysis of different future objects update strategies in ProActive. In 2007 IEEE International Parallel and Distributed Processing Symposium (2007), pp. 1–7.

This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
Transfer of copyright agreement: When the article is accepted for publication, I, as the author and the representative of the coauthors, hereby agree to transfer to Studia Universitatis Babes-Bolyai, Series Informatica, all rights, including those pertaining to electronic forms and transmissions, under existing copyright laws, except for the following, which the authors specifically retain: the authors can use the material however they want as long as it fits the NC ND terms of the license. The authors have all rights for reuse according to the below license.