Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Concurrency with Modern C++

You're reading from   Concurrency with Modern C++ What every professional C++ programmer should know about concurrency.

Arrow left icon
Product type Paperback
Published in Dec 2019
Publisher
ISBN-13 9781839211027
Length 543 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Rainer Grimm Rainer Grimm
Author Profile Icon Rainer Grimm
Rainer Grimm
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

1. Reader Testimonials FREE CHAPTER
2. Introduction 3. Concurrency with Modern C++ 4. Memory Model 5. Multithreading 6. Parallel Algorithms of the Standard Template Library 7. The Near Future: C++20 8. Case Studies 9. The Future: C++23 10. Patterns and Best Practices 11. Synchronisation Patterns 12. Concurrent Architecture 13. Best Practices 14. Lock-Based Data Structures 15. Challenges 16. The Time Library 17. CppMem - An Overview 18. Glossary 19. Index

Coroutines

Coroutines are functions that can suspend and resume their execution while keeping their state. The evolution of functions goes in C++ one step further. Coroutines are with high probability part of C++20.

What I present in this section as a new idea in C++20 is quite old. The term coroutine was coined by Melvin Conway. He used it in his publication on compiler construction in 1963. Donald Knuth called procedures a special case of coroutines. Sometimes, it just takes a while to get your ideas accepted.

With the new keywords co_await and co_yield, C++20 extends the execution of C++ functions with two new concepts.

Thanks to co_await expression it is possible to suspend and resume the execution of the expression. If you use co_await expression in a function func, the call auto getResult = func() does not block if the result of the function is not available. Instead of resource-consuming blocking, you have resource-friendly waiting.

co_yield expression allows it to write a...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime