A semaphore can be used to guard critical sections from simultanuous access from different threads. For example:
#include "wsemaphore.h" WindowsUtils::Semaphore s; int shared_count; void increment() { s.wait(); ++shared_count; // critical section s.post(); } void decrement() { s.wait(); --shared_count; // critical section s.post(); }
Class Sempahore is obtained from [WIN32SEMAPHORE] at [BBDSOFT] with this license.
Classes | |
| class | Semaphore |
| encapsulate Win32 semaphore. More... | |