Adding State to the Update Notification Pattern, Part 3 -- Raymond Chen
In our continued exploration of efficient stateful update notifications, we delve into optimizing our existing solution to mitigate unnecessary background work. By introducing periodic checks for pending text and leveraging mutex protection, we aim to streamline the process and enhance performance. However, as we unravel these optimizations, we confront the complexities of managing thread safety and delve into the intricacies of background thread synchronization.Adding State to the Update Notification Pattern, Part 3
by Raymond Chen
From the article:
Last time, we developed a stateful but coalescing update notification, and we noted that the code does a lot of unnecessary work because the worker thread calculates all the matches, even if the work has been superseded by another request.
We can add an optimization to abandon the background work if it notices that its efforts are going to waste: Periodically check whether there is any pending text. This will cost us a mutex, however, to protect access to
m_pendingTextfrom multiple threads.

Registration is now open for CppCon 2024! The conference starts on September 15 and will be held
std::format allows us to format values quickly and safely. Spencer Collyer demonstrates how to provide formatting for a simple user-defined class.
In this episode, you learn how default parameters work and why you shouldn't put them on virtual member functions.
The last episode of the series about SObjectizer and message passing: