From Functions to CoroutinesFrom Functions to Coroutines 40 Years Evolution Rainer Grimm Training, Coaching, and Technology Consulting www.ModernesCpp.netEvolution of Callable templateT invoke(Func 0 码力 | 29 页 | 510.47 KB | 6 月前3
Deciphering C++ Coroutines2/55 Deciphering Coroutines - Part 2 Mastering Asynchronous Control Flow Andreas Weis CppCon 20243/55 About me - Andreas Weis (he/him) ComicSansMS cpp@andreas-weis.net Co-organizer of the Munich best-practice talk.16/55 A mental model for coroutines: Cooperative Threads void spawn_task () { // ... Result r = outer_function (); }16/55 A mental model for coroutines: Cooperative Threads void spawn_task mental model for coroutines: Cooperative Threads PartialResult middle_function () { auto r = inner_function (); return PartialResult :: from_io_result (r); }16/55 A mental model for coroutines: Cooperative0 码力 | 156 页 | 1.79 MB | 6 月前3
Coroutines and Structured Concurrency in PracticeChallenges when onboarding coroutines A lot of existing code mostly callback-based A custom-built I/O event loop predates Asio by a decade fine-tuned for specific use cases Somewhat conservative conservative audience real benefit needs to be demonstrated to justify switchingCallbacks vs coroutines // read length auto len = make_unique(); async_read(socket, buffer(len.get(), sizeof(int32_t)) use_awaitable); // ...handle data... Local variable Manual lifetime managementCallbacks vs coroutines // read length auto len = make_unique (); async_read(socket, buffer(len.get(), sizeof(int32_t)) 0 码力 | 103 页 | 1.98 MB | 6 月前3
How Meta Made Debugging Async Code Easier with Coroutines and Senders0 码力 | 131 页 | 907.41 KB | 6 月前3
Behavioral Modeling in HW/SW Co-design Using C++ CoroutinesJeffrey E. Erickson cppcon 2023 1cppcon 2023 Behavioral Modeling in HW/SW Co-design using C++ coroutines Jeffrey E Erickson, Ph.D. Sebastian Schönberg, Ph.D.© 2023 Intel Corporation and Jeffrey E. Erickson Jeffrey E. Erickson cppcon 2023 8 Coroutines are an enabling language feature • To date, coroutines have been about execution and workloads • In the modeling context, coroutines… • Provide syntactic sugar Handle parallelism in a way that isn’t clunky • Scale across large and complex HW interactions But, coroutines lack comprehensive standard library support • We used concurrencppIntel Confidential Department0 码力 | 44 页 | 584.69 KB | 6 月前3
Coroutine Patterns and How to Use Them: Problems and Solutions Using Coroutines in a Modern Codebaseknowledge Francesco Zoffoli - Coroutine Patterns and How to Use Them - CppCon 2023 5Motivation Coroutines introduce new paradigm Francesco Zoffoli - Coroutine Patterns and How to Use Them - CppCon 2023 CppCon 2023 11Overview – Executor • Executes synchronous functions • Could be multi-threaded • Coroutines are split in synchronous functions Francesco Zoffoli - Coroutine Patterns and How to Use Them CppCon 2023 19 [1] https://ericniebler.com/2020/11/08/structured-concurrency/Lifetime Member coroutines implicitly capture this Francesco Zoffoli - Coroutine Patterns and How to Use Them - CppCon0 码力 | 70 页 | 1.45 MB | 6 月前3
Combining Co-Routines and Functions into a Job System(*function)() • struct Function{}: std::function, thread, type and id for logging • Tags • Coroutines of type Coro • Thread, type and id with operator() • std::tuple and std::vector containing and Functions into a Job System - CppCon 2021 18 / 39 Coroutines • Normal functions (synchronous) • Stack frame • Gone after return • Coroutines (asynchronous) can • Suspend to wait for a result, resume Hlavacs – Combining Co-Routines and Functions into a Job System - CppCon 2021 20 / 39 Coroutines in VGJS • Coroutines are created by calling them Coro retObj = driver(13); //create coro fr, return 0 码力 | 39 页 | 1.23 MB | 6 月前3
Working with Asynchrony Generically: A Tour of C++ ExecutorsUnder the hood of a concurrent operation 5. Implementing a simple algorithm 6. Senders and coroutines Part 2: 1. Structured concurrency 2. Cancellation 3. An extended example3 GOALS FOR THE EXECUTORS of abstractions (aka, concepts) derived from the algorithms • Efficient interoperability with coroutines • An open and extensible way to specify where, how, and when work should happen … including some async algorithms: • E.g., then, when_all, sync_wait, let_* • Utilities for integration with C++20 coroutines5 Example 1: Launching concurrent work6 EXAMPLE: LAUNCHING CONCURRENT WORK namespace ex = std::execution;0 码力 | 121 页 | 7.73 MB | 6 月前3
C++20: An (Almost) Complete Overviewvoting, expected to be formally published by the end of 2020.4 Agenda Modules Ranges Coroutines Concepts Lambda Expression Changes [=, this] as Lambda Capture Templated Lambda Expressions views::take(10) }; “C++20 Ranges in Practice” -- Tristan Brindle Thursday, September 17 • 12:00coroutines15 Coroutines What’s a coroutine? A function, with one of the following: co_await: suspends not allowed)16 Coroutines What are coroutines used for? They simplify implementing: Generators Asynchronous I/O Lazy computations Event driven applications17 Coroutines C++20 contains0 码力 | 85 页 | 512.18 KB | 6 月前3
From Eager Futures/Promises to Lazy Continuations: Evolving an Actor Library Based on Lessons Learned from Large-Scale Deploymentsexpensive, not conducive to correctness use coroutines …possible solutions just wait … use threads … too expensive, not conducive to correctness use coroutines … circa 2009possible solutions just wait correctness use coroutines … circa 2009 use a different language (e.g., Erlang) …possible solutions just wait … use threads … too expensive, not conducive to correctness use coroutines … circa 2009 possible solutions just wait … use threads … too expensive, not conducive to correctness use coroutines … circa 2009 use a different language (e.g., Erlang) … or bring Erlang to C++! use callbacks0 码力 | 264 页 | 588.96 KB | 6 月前3
共 30 条
- 1
- 2
- 3
相关搜索词
FromFunctionstoCoroutinesDecipheringC++andStructuredConcurrencyinPracticeHowMetaMadeDebuggingAsyncCodeEasierwithSendersBehavioralModelingHWSWCodesignUsingCoroutinePatternsUseThemProblemsSolutionsModernCodebaseCombiningRoutinesintoJobSystemWorkingAsynchronyGenericallyTourofExecutors20AnAlmostCompleteOverviewEagerFuturesPromisesLazyContinuationsEvolvinganActorLibraryBasedonLessonsLearnedfromLargeScaleDeployments













