Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / skia / src / ports / SkMutex_win.h
index d12fd03..fe06336 100644 (file)
 #endif
 
 // On Windows, SkBaseMutex and SkMutex are the same thing,
-// we can't easily get rid of static initializers.
-class SkMutex {
+// we can't easily get rid of static initializers. However,
+// we preserve the same inheritance pattern as other platforms
+// so that we can forward-declare cleanly.
+struct SkBaseMutex {
 public:
-    SkMutex() {
+    SkBaseMutex() {
         InitializeCriticalSection(&fStorage);
         SkDEBUGCODE(fOwner = 0;)
     }
 
-    ~SkMutex() {
+    ~SkBaseMutex() {
         SkASSERT(0 == fOwner);
         DeleteCriticalSection(&fStorage);
     }
@@ -59,18 +61,19 @@ public:
         SkASSERT(GetCurrentThreadId() == fOwner);
     }
 
-private:
-    SkMutex(const SkMutex&);
-    SkMutex& operator=(const SkMutex&);
-
+protected:
     CRITICAL_SECTION fStorage;
     SkDEBUGCODE(DWORD fOwner;)
+
+private:
+    SkBaseMutex(const SkBaseMutex&);
+    SkBaseMutex& operator=(const SkBaseMutex&);
 };
 
-typedef SkMutex SkBaseMutex;
+class SkMutex : public SkBaseMutex { };
 
 // Windows currently provides no documented means of POD initializing a CRITICAL_SECTION.
-#define SK_DECLARE_STATIC_MUTEX(name) static SkBaseMutex name
-#define SK_DECLARE_GLOBAL_MUTEX(name) SkBaseMutex name
+// As a result, it is illegal to SK_DECLARE_STATIC_MUTEX in a function.
+#define SK_DECLARE_STATIC_MUTEX(name) namespace{} static SkBaseMutex name
 
 #endif