On Composing Asynchronous Operations

  • R Lupșa Department of Computer Science, Babes-Bolyai University, 1, M. Kogalniceanu Street, 400084, Cluj-Napoca, Romania
  • L Lupșa Department of Computer Science, Babes-Bolyai University, 1, M. Kogalniceanu Street, 400084, Cluj-Napoca, Romania

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

[1] C++ reference. extensions for concurrency. https://en.cppreference.com/w/cpp/experimental/future/then. Accessed: 2023.
[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.
Published
2023-12-22
How to Cite
LUPȘA, R; LUPȘA, L. On Composing Asynchronous Operations. Studia Universitatis Babeș-Bolyai Informatica, [S.l.], v. 68, n. 2, p. 41-52, dec. 2023. ISSN 2065-9601. Available at: <https://www.cs.ubbcluj.ro/~studia-i/journal/journal/article/view/92>. Date accessed: 18 may 2024. doi: https://doi.org/10.24193/subbi.2023.2.03.
Section
Articles