Index: src/shared/CriticalSection.h |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/src/shared/CriticalSection.h |
@@ -0,0 +1,40 @@ |
+#ifndef CRITICAL_SECTION_H |
+#define CRITICAL_SECTION_H |
+ |
+class CriticalSection |
+{ |
+public: |
+ CriticalSection() |
+ { |
+ InitializeCriticalSection(§ion); |
+ } |
+ |
+ ~CriticalSection() |
+ { |
+ DeleteCriticalSection(§ion); |
+ } |
+ |
+ class Lock |
+ { |
+ public: |
+ Lock(CriticalSection& cs) |
+ : section(&cs.section) |
+ { |
+ EnterCriticalSection(section); |
+ } |
+ |
+ ~Lock() |
+ { |
+ LeaveCriticalSection(section); |
+ } |
+ private: |
+ LPCRITICAL_SECTION section; |
+ Lock(const Lock&); |
+ Lock& operator=(const Lock&); |
+ }; |
+private: |
+ CRITICAL_SECTION section; |
+ CriticalSection(const CriticalSection&); |
+ CriticalSection& operator=(const CriticalSection&); |
+}; |
+#endif |