LEFT | RIGHT |
(no file at all) | |
| 1 #ifndef CRITICAL_SECTION_H |
| 2 #define CRITICAL_SECTION_H |
| 3 |
| 4 class CriticalSection |
| 5 { |
| 6 public: |
| 7 CriticalSection() |
| 8 { |
| 9 InitializeCriticalSection(§ion); |
| 10 } |
| 11 |
| 12 ~CriticalSection() |
| 13 { |
| 14 DeleteCriticalSection(§ion); |
| 15 } |
| 16 |
| 17 class Lock |
| 18 { |
| 19 public: |
| 20 Lock(CriticalSection& cs) |
| 21 : section(&cs.section) |
| 22 { |
| 23 EnterCriticalSection(section); |
| 24 } |
| 25 |
| 26 ~Lock() |
| 27 { |
| 28 LeaveCriticalSection(section); |
| 29 } |
| 30 private: |
| 31 LPCRITICAL_SECTION section; |
| 32 Lock(const Lock&); |
| 33 Lock& operator=(const Lock&); |
| 34 }; |
| 35 private: |
| 36 CRITICAL_SECTION section; |
| 37 CriticalSection(const CriticalSection&); |
| 38 CriticalSection& operator=(const CriticalSection&); |
| 39 }; |
| 40 #endif |
LEFT | RIGHT |