Index: src/shared/Utils.h |
=================================================================== |
--- a/src/shared/Utils.h |
+++ b/src/shared/Utils.h |
@@ -25,4 +25,43 @@ |
return trimmed; |
} |
+namespace |
Wladimir Palant
2013/06/17 12:57:24
If it's a public class then it shouldn't be declar
|
+{ |
+ 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 // UTILS_H |