Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/shared/CriticalSection.h

Issue 11012013: Hanging resolved (critical sections unlocking) (Closed)
Patch Set: Comments addressed Created June 25, 2013, 11:56 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/plugin/PluginFilter.cpp ('k') | src/shared/Utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(&section);
+ }
+
+ ~CriticalSection()
+ {
+ DeleteCriticalSection(&section);
+ }
+
+ 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
« no previous file with comments | « src/plugin/PluginFilter.cpp ('k') | src/shared/Utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld