This course will introduce you to modern C++ concurrency on the Windows operating system. Unfortunately, standard or portable concurrency is still in its infancy so a comprehensive study of concurrency cannot get away from the practical and platform-specific aspects of the craft. As such, this course uses the Windows operating system as the playground to explore concurrency in C++. This course will prepare you with a deep understanding of threads and synchronization at the OS level, including modern synchronization primitives such as slim reader/writer locks and condition variables. You will learn all about the mighty Windows thread pool API and the Concurrency Runtime. Finally, you will be introduced to some of the shortcomings that plague the C++11 Thread Support Library.
Getting Started My name is Kenny Kerr and I'd like to welcome you to the Modern C++ Concurrency course here on Pluralsight. This course is about the practical application of the Modern C++ language to the field of concurrency or concurrent programming. Concurrency is everywhere, it doesn't matter whether you're writing a console application, a shiny new game for one of the app stores, or a server side code for a website or an investment bank. As developers we need to know how to exploit the concurrency inherent in the machines we're controlling. We need to know how to write responsive software and in software that scales with the available hardware. We need to know how to improve throughput, taking into account the inherent latencies among the different peripherals and subsystems we inevitably have to deal with. We need to consider processes and threads, we need to consider the units of work that we need to perform. And the data structures we use as such that they are naturally scalable. As with my previous Modern C++ libraries course, this is going to be a practical and even pragmatic study of Modern C++ concurrency using the Windows operating system as the playground.
Threads Welcome back to Modern C++ Concurrency, my name is Kenny Kerr and in this module we're going to examine Windows threads and the essential synchronization primitives provided by the operating system. While I do encourage developers to use higher level abstractions, such as thread pools and a synchronous coding patterns, it helps to understand how threads of execution actually come into existence and how to perform fine grain synchronization. That's what this module is about, it will help you to understand how the operating system thinks about concurrency and how many of the higher level abstractions, that we'll cover later on in this course, are built.
Synchronization Welcome back to Modern C++ Concurrency. My name is Kenny Kerr. And in this module, we're going to go deeper into thread synchronization and the primitives, or building blocks, that the operating system provides for coordination work to define critical sections of code to protect data, and so on. Once again, this module focuses on Windows-specific threads and synchronization. Later in this course, we'll cover other runtimes and abstractions, which may be more portable, but those ultimately boil down to the core synchronization primitives offered by the Windows Operating System itself.
Condition Variables Welcome back to Modern C++ Concurrency. My name is Kenny Kerr, and in this module, we're going to take a more practical look at writing concurrent data structures. We're going to walk through the implementation of a blocking queue, a relatively simple data structure or container, that presents some interesting, concurrency-related challenges and pitfalls. I don't generally recommend blocking queues. Anything non-blocking is generally preferred, but the concept is simple to grasp and offers up a lot of practical experience in concurrency design. Along the way, we'll discover some of the motivation behind the condition variable, concurrency pattern, and I'll introduce you to another modern synchronization primitive offered by Modern Versions of Windows, the aptly named Condition Variable.
The Windows Thread Pool - Part 2 Welcome back to Modern C++ Concurrency. My name is Kenny Kerr, and in this module, we're going to continue our study of the Windows Thread Pool. This module focuses on synchronization, timers, and timeouts, and ultimately cleanup and cancellation. These are all topics in concurrency that have been traditionally rife with complexity. Fortunately, the Windows Thread Pool does all of the heavy lifting and leaves us with an elegant abstraction.
The Concurrency Runtime In these final two modules, I'm going to cover two Concurrency libraries that while interesting are likely to see the most change over the next few years. The first of these is The Concurrency Runtime. What I've tried to do thus far in this course is lay a foundation for Modern C++ Concurrency, based on the Concurrency primitives that are foundational on the Windows operating system, and more generally on all platforms. Wherever you go, there are likely to be operating system threads, synchronization primitives, and more than likely thread pools. On top of these you will likely find a range of Concurrency libraries exhibiting value semantics, or at least trying to, and raising the level of abstraction away from the details of threads and synchronization. That's the direction in which the C++ community needs to go. It does no good creating new abstractions that just represent threads all over again. Anyway, probably one of the most ambitious efforts is The Concurrency Runtime that ships with Visual C++, and that's the focus of this module. The Concurrency Runtime is itself a large topic of study. It comprises over a number of libraries, but to keep things focused and practical, I'll be focusing on the Parallel Patterns Library, and focus on examples rather than too much theory. The Parallel Patterns Library and Intel's Threading Building Blocks are quite similar. That's because Microsoft and Intel collaborated to produce their respective libraries, so you're going to find a lot of overlap as you study the two implementations. Although the Concurrency Runtime is quite mature and is unlikely to change all that much, many of its designs and capabilities are being considered for adoption into standard C++, so we're likely to see many of these reshaped slightly and rebranded, so to speak, under the standard namespace in the future.
The C++11 Thread Support Library And now we come to the awkward part of this modern C++ Concurrency course. While the C++ language has been used to write Concurrency software for more than 20 years, it has never been possible to do so in a standard and portable way, since the C++ language or standard has been silent with regards to concurrency; at least up until the C++11 standardization process. Now, C++ developers can finally say with some pride that, and I quote, "all modern programming languages provide support for this. " That's taken from Stroustrup's 4th Edition of the C++ Programming Language. The C++ standard library does now finally include a memory model, support for lock-free atomics or interlocked operations, the ability to create threads and locks, as well as a task-based library. The trouble is that this first attempt at Concurrency is just not very good, and I anticipate that a large part of the library's initial offering will eventually be deprecated and replaced with something more realistic. But let's take a look at what is offered, and we'll start with the standard thread class.