Scenario 3: Call a Function When a Single Kernel Object Becomes Signaled

Microsoft discovered that many applications spawn threads simply to wait for a kernel object to become signaled. Once the object is signaled, the thread posts some sort of notification to another thread and then loops back, waiting for the object to signal again. This is exactly the scenario you saw earlier in the Batch example, where a dedicated work item was needed to monitor when the real actions were finished by waiting for kernel events signaled when each real action callback ended. Some developers even write code in which several threads wait on a single object. This is incredibly wasteful of system resources. Sure, there is a lot less overhead involved in creating ...

Get Windows® via C/C++, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.