• Post category:StudyBullet-13
  • Reading time:11 mins read


C++20, Multithreading, Concurrency, Modern C++, C++11,C++14, C++17, Parallel algorithms, Coroutines, Synchronization

What you will learn

Mastered the fundamentals of C++ concurrency syntax, enabling you to write efficient and high-performance concurrent code with confidence.

Gained hands-on experience with the latest C++20 concurrency features, such as coroutines, cooperative cancellation, std::jthread, semaphore, barrier, and latch

Enhanced your problem-solving skills by learning how to leverage modern C++ concurrency techniques to tackle complex and time-sensitive tasks in your projects.

Acquired the ability to identify and apply the most suitable concurrency tools for various scenarios, ensuring that your code is both maintainable and scalable.

Developed a strong foundation in C++ concurrency that will serve as a stepping stone for further exploration and mastery of advanced topics in concurrent and pa

Description

Welcome to “Turbocharge Your C++ with Concurrency: A Weekend Crash Course”!

Are you a programmer who has recently learned C++ and wants to unlock the true power of modern C++ concurrency? Look no further! In just one weekend, we will help you quickly grasp the essentials of C++ concurrency and supercharge your coding skills.

In this fast-paced and intensive course, we will focus exclusively on the syntax of C++ concurrency, allowing you to understand and apply the features efficiently in your own projects. We know your time is valuable, so we’ve carefully designed short, easy-to-follow lectures that introduce syntax and explain its usage through concise examples. This way, you’ll maximize your learning experience without getting bogged down in unnecessary details.

Our curriculum includes the latest C++20 features, ensuring that you are up-to-date with the most cutting-edge concurrency tools. You’ll learn about coroutines, cooperative cancellation, std::jthread, semaphore, barrier, and latches. These powerful features will take your C++ skills to the next level and make you a more effective and competitive programmer in today’s fast-evolving tech landscape.

This course is perfect for you if you’ve just learned C++ and are eager to dive into the world of concurrency without spending weeks on theory and complex projects. By the end of this weekend, you’ll have a solid understanding of modern C++ concurrency syntax and will be ready to apply it in real-world scenarios.

So, what are you waiting for? Enroll now, and let’s turbocharge your C++ skills together with this weekend’s crash course!


Get Instant Notification of New Courses on our Telegram channel.


Why is Mastering Modern C++ Concurrency Features Crucial for Today’s Programmers?

Understanding and utilizing modern concurrency features built into the C++ language is of paramount importance in today’s fast-paced, technology-driven world. As software applications and systems become increasingly complex and resource-intensive, the ability to write efficient, high-performance concurrent code is a highly sought-after skill. By learning modern C++ concurrency features, you will unlock the true potential of multicore processors, significantly improving the performance and responsiveness of your applications. This knowledge not only sets you apart as a programmer but also allows you to tackle complex, real-world problems more effectively. By investing in your skills and mastering modern C++ concurrency, you will stay ahead of the curve, becoming a valuable asset in the competitive software development landscape and opening up a world of opportunities in your career.

Evolution of the C++ Memory Model

The C++ concurrency model has evolved significantly from C++11 to C++20, introducing new language features and library components that provide more powerful and flexible support for concurrent programming. Here are some of the significant changes that have occurred:

  1. C++11: C++11 introduced the first set of language-level concurrency features, including the std::thread class for creating and managing threads, mutexes and condition variables for synchronization, and atomic types for lock-free programming. C++11 also defined the Sequential Consistency-Data Race Free (SC-DRF) memory model, which guarantees correct behavior for well-synchronized programs.
  2. C++14: C++14 introduced several improvements to the concurrency features introduced in C++11, including new constructors and member functions for std::thread, support for heterogeneous lookup in concurrent containers, and enhancements to the std::atomic template.
  3. C++17: C++17 introduced several new concurrency features and enhancements, including support for parallel algorithms in the Standard Template Library (STL), structured bindings for returning multiple values from std::thread functions, and support for shared_mutex for shared read access and exclusive write access. C++17 also introduced a new memory model that provides stronger guarantees for atomic operations.
  4. C++20: C++20 builds on the concurrency features introduced in previous language versions and adds several new features and enhancements. These include the atomic_ref class, which provides a safer way to access shared variables without the need for explicit synchronization, improvements to the memory model to reduce the need for explicit fences and barriers, and enhancements to the coroutines library that make it easier to write asynchronous code.

The evolution of the C++ concurrency model from C++11 to C++20 has provided developers with a more powerful and flexible set of tools for writing efficient and correct concurrent programs. The new language features and library components introduced in each version have addressed many of the challenges and limitations of earlier versions. In addition, they have made concurrent programming in C++ more accessible and easier to use.

English
language

Content

Introduction

Course Objectives

Managing Threads ( C++11 onwards )

Launching Threads
Passing arguments to threads
Launching thread Excercise – C++20 to C++14 porting!
Member functions of std::thread ( C++11 ) and std::jthread ( C++20 )
Member Function Quiz
Cooperative Cancellation feature released in C++20
Cooperative Cancellation General workflow possible in programs using C++20
Cooperative Cancellation Quiz
Practical considerations of using threads in C++ 11/14/17/20
When to use std::async?
async vs thread?

Synchronization in multhreaded applications using C++ concurrency features

Overview of synchronization mechanisms
Introduction to latches introduced in C++20
Code example of latches ( needs C++20 )
Use cases of std::latch in programs using C++20
std::latch quiz
introduction to barriers introduced in C++20
Code example of std::barrier (needs C++20)
Use cases of std::barrier in programs using C++20
std::barrier quiz

Futures ( C++11 onwards )

Introduction to futures in Modern C++
Member functions of std::future
Blocking and Polling usage of std::future
std::future Quiz
Member functions of std::promise
Passing data using std::future and std::promise
Passing exception using std::future and std::promise
Using futures in programs
Futures in C++ are single shot!
Shared futures
Shared futures in action
std::async revisted as concurrency mechanism

Mutex ( C++11 onwards )

Introduction to std::mutex
Locks and Mutexes in modern C++ for seamless life time management
Code example of locks and mutexes in modern C++
Locks and mutexes

Conditional Variables ( C++11 onwards )

Busy waiting mechanism
Conditional Variables in modern C++
Co-operative cancellation using conditional variables (using C++20 )
Conditional Variables Quiz

Semaphore ( C++20 onwards )

Introduction to Semphores (since C++20)
Member functions of std::semaphore (since C++ 20)
Using semaphores in programs built with C++20
Sempahores Quiz

Atomics ( C++11 onwards )

Basics of Atomics
Overloaded operators with atomics
Cautions while using atomic overloads
Member functions of atomics
Operators Quiz
More member functions of atomics
Summary and advice while working with atomics

Parallel Algorithms ( since C++17)

Introduction to parallel algorithms
Execution policies for parallel algorithms ( C++17 and C++20 )
Quick demo parallel algorithms using concurrency

Coroutines ( as shipped in C++20)

Coroutines Disclaimer
Coroutines Quiz
Basic flow diagram of control of coroutines in C++20
Member functions of co-routines task structure shipped in C++20
Flowchart of coroutines execution using the API availble in C++20

Closing remarks

Third party libraries ( can be used with C++ 11, C++14, C++17, C++20 )
Conclusion
[Bonus Lecture]