Cooperative Interruption of a Thread in C++20
A typical question in my C++ seminars is: Can a thread be killed? Before C++20, my answer is no. With C++20, you can ask a thread politely for its interruption.
This author has not written his bio yet.
But we are proud to say that Rainer Grimm contributed 656 entries already.
A typical question in my C++ seminars is: Can a thread be killed? Before C++20, my answer is no. With C++20, you can ask a thread politely for its interruption.
In my last post, I introduced latches in C++20. A latch enables its threads to wait until a counter becomes zero. Additionally to a latch, its big sibling barrier can be used more than once. Today, I write about barriers and present atomic smart pointers.
Latches and barriers are coordination types that enable some threads to wait until a counter becomes zero. You can use a std::latch only once, but you can use a std::barrier more than once. Today, I have a closer look at latches.
Semaphores are a synchronization mechanism used to control concurrent access to a shared resource. They also allow it to play ping-pong.
Last week, I launched a quiz. The price was it to win one of the five vouchers for the book “The Modern C++ Programming Cookbook” 2en Edition by Marius Bancila.
I give away five vouchers for my book “C++20”. In return, I have a question about the Big Four: concepts, ranges, coroutines, and modules. Which feature excites your most and why?
After the introduction to std::atomic_flag in my last post, Synchronization with Atomics in C++20, I want to dive deeper. Today, I created a ping-pong game using condition variables, std::atomic_flag and std::atomic<bool>. Let’s play.
I’m proud to present the early release of my book to C++20 on LeanPub. The book is 50 % done and has more than 300 pages and 150 code examples of content. I will update the book at least two times in 2021. Of course, you will get each update of the book.
Sender/receiver workflows are pretty common for threads. In such a workflow, the receiver is waiting for the sender’s notification before it continues to work. There are various ways to implement these workflows. With C++11, you can use condition variables or promise/future pairs; with C++20, you can use atomics.
Atomics receives a few essential extensions in C++20. Today, I start with the new data type std::atomic_ref.