Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
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
Asynchronous Programming with C++

You're reading from   Asynchronous Programming with C++ Build blazing-fast software with multithreading and asynchronous programming for ultimate efficiency

Arrow left icon
Product type Paperback
Published in Nov 2024
Publisher Packt
ISBN-13 9781835884249
Length 424 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (2):
Arrow left icon
Javier Reguera Salgado Javier Reguera Salgado
Author Profile Icon Javier Reguera Salgado
Javier Reguera Salgado
Juan Rufes Juan Rufes
Author Profile Icon Juan Rufes
Juan Rufes
Arrow right icon
View More author details
Toc

Table of Contents (21) Chapters Close

Preface 1. Part 1:Foundations of Parallel Programming and Process Management FREE CHAPTER
2. Chapter 1: Parallel Programming Paradigms 3. Chapter 2: Processes, Threads, and Services 4. Part 2: Advanced Thread Management and Synchronization Techniques
5. Chapter 3: How to Create and Manage Threads in C++ 6. Chapter 4: Thread Synchronization with Locks 7. Chapter 5: Atomic Operations 8. Part 3: Asynchronous Programming with Promises, Futures, and Coroutines
9. Chapter 6: Promises and Futures 10. Chapter 7: The Async Function 11. Chapter 8: Asynchronous Programming Using Coroutines 12. Part 4: Advanced Asynchronous Programming with Boost Libraries
13. Chapter 9: Asynchronous Programming Using Boost.Asio 14. Chapter 10: Coroutines with Boost.Cobalt 15. Part 5: Debugging, Testing, and Performance Optimization in Asynchronous Programming
16. Chapter 11: Logging and Debugging Asynchronous Software 17. Chapter 12: Sanitizing and Testing Asynchronous Software 18. Chapter 13: Improving Asynchronous Software Performance 19. Index 20. Other Books You May Enjoy

Summary

In this chapter, we learned how to use the lock-based synchronization primitives provided by the C++ Standard Library.

We started with an explanation of race conditions and the need for mutual exclusion. Then, we studied std::mutex and how to use it to solve race conditions. We also learned about the main problems when synchronizing with locks: deadlock and livelock.

After learning about mutexes, we studied condition variables and implemented a synchronized queue using mutex and condition variables. Finally, we saw the new synchronization primitives introduced in C++20: semaphores, latches, and barriers.

Finally, we studied the mechanisms provided by the C++ Standard Library to run a function just one time.

In this chapter, we learned about the basic building blocks of thread synchronization and the foundation of asynchronous programming with multiple threads. Lock-based thread synchronization is the most used method to synchronize threads.

In the next chapter...

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 $19.99/month. Cancel anytime