My tutorial and take on C++20 coroutines
Over the last 25 years, I’ve written a lot of event-driven code in C++. A typical example of event-driven code is registering a callback that gets invoked every time a socket has data to be read. Once you have read an entire message, possibly after many invocations, you parse the message and invoke another callback from a higher layer of abstraction, and so forth. This kind of code is painful to write because you have to break your code up into a bunch of different functions that, because they are different functions, don’t share local variables. As an example, here’s a subset of the methods on the smtpd class of Mail Avenger, my SMTP server written in C++03: Step 1, cmd_rcpt, seems like a reasonable function, called in response to a client issuing an SMTP “RCPT” command. Processing the RCPT command depends on certain information being cached about the client. If the information if not cached, it launches an asynchronous task to probe the client and returns. The asynchronous task, when
My tutorial and take on C++20 coroutines ←Index View as PDF Introduction Over the last 25 years, I’ve written a lot of event-driven code in C++. A typical example of event-driven code is registering a callback that gets invoked every time a socket has data to be read. Once you have read an entire message, possibly after many invocations, you parse the message and invoke another callback from a higher layer of abstraction, and so forth. This kind of code is painful to write because you have to break your code up into a bunch of different functions that, because they are different functions, don
Explore this link on the map →saved by
related reading
- Daily bit(e) of C++ | Coroutines: step by stepsimontoth.substack.com
- python - How does asyncio actually work? - Stack Overflowstackoverflow.com
- Reading 15: Promisesweb.mit.edu
- 500 Lines or LessA Web Crawler With asyncio Coroutinesaosabook.org
- TypeScript Structured Concurrencythecandidstartup.org
- Notes on structured concurrency, or: Go statement considered harmful - njs blogvorpus.org
- Microtasks and event looptr.javascript.info
- Let futures be futureswithout.boats
- Futures and promises - Wikipediaen.wikipedia.org
- async/await on embedded Rust - Ferrous Systemsferrous-systems.com
- What Async Promised and What it Delivered — Causalitycausality.blog
- Why async Rust?without.boats