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

Unified Diff: src/shared/Utils.h

Issue 11012013: Hanging resolved (critical sections unlocking) (Closed)
Patch Set: Using CriticalSection class instead Created June 17, 2013, 10:03 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
« src/plugin/PluginFilter.h ('K') | « src/plugin/PluginFilter.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(&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 // UTILS_H
« src/plugin/PluginFilter.h ('K') | « src/plugin/PluginFilter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld