OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkMutex_win_DEFINED | 8 #ifndef SkMutex_win_DEFINED |
9 #define SkMutex_win_DEFINED | 9 #define SkMutex_win_DEFINED |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... | |
24 #ifdef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED | 24 #ifdef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED |
25 # undef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED | 25 # undef WIN32_IS_MEAN_WAS_LOCALLY_DEFINED |
26 # undef WIN32_LEAN_AND_MEAN | 26 # undef WIN32_LEAN_AND_MEAN |
27 #endif | 27 #endif |
28 #ifdef NOMINMAX_WAS_LOCALLY_DEFINED | 28 #ifdef NOMINMAX_WAS_LOCALLY_DEFINED |
29 # undef NOMINMAX_WAS_LOCALLY_DEFINED | 29 # undef NOMINMAX_WAS_LOCALLY_DEFINED |
30 # undef NOMINMAX | 30 # undef NOMINMAX |
31 #endif | 31 #endif |
32 | 32 |
33 // On Windows, SkBaseMutex and SkMutex are the same thing, | 33 // On Windows, SkBaseMutex and SkMutex are the same thing, |
34 // we can't easily get rid of static initializers. | 34 // we can't easily get rid of static initializers. However, |
35 class SkMutex { | 35 // we preserve the same inheritance pattern as other platforms |
36 // so that we can forward-declare cleanly. | |
37 struct SkBaseMutex { | |
mtklein
2014/06/30 22:24:01
Don't you have to do it the other way around? SkB
| |
38 | |
39 }; | |
40 | |
41 class SkMutex : public SkBaseMutex { | |
36 public: | 42 public: |
37 SkMutex() { | 43 SkMutex() { |
38 InitializeCriticalSection(&fStorage); | 44 InitializeCriticalSection(&fStorage); |
39 SkDEBUGCODE(fOwner = 0;) | 45 SkDEBUGCODE(fOwner = 0;) |
40 } | 46 } |
41 | 47 |
42 ~SkMutex() { | 48 ~SkMutex() { |
43 SkASSERT(0 == fOwner); | 49 SkASSERT(0 == fOwner); |
44 DeleteCriticalSection(&fStorage); | 50 DeleteCriticalSection(&fStorage); |
45 } | 51 } |
(...skipping 14 matching lines...) Expand all Loading... | |
60 } | 66 } |
61 | 67 |
62 private: | 68 private: |
63 SkMutex(const SkMutex&); | 69 SkMutex(const SkMutex&); |
64 SkMutex& operator=(const SkMutex&); | 70 SkMutex& operator=(const SkMutex&); |
65 | 71 |
66 CRITICAL_SECTION fStorage; | 72 CRITICAL_SECTION fStorage; |
67 SkDEBUGCODE(DWORD fOwner;) | 73 SkDEBUGCODE(DWORD fOwner;) |
68 }; | 74 }; |
69 | 75 |
70 typedef SkMutex SkBaseMutex; | |
71 | |
72 // Windows currently provides no documented means of POD initializing a CRITICAL _SECTION. | 76 // Windows currently provides no documented means of POD initializing a CRITICAL _SECTION. |
73 #define SK_DECLARE_STATIC_MUTEX(name) static SkBaseMutex name | 77 #define SK_DECLARE_STATIC_MUTEX(name) static SkBaseMutex name |
74 #define SK_DECLARE_GLOBAL_MUTEX(name) SkBaseMutex name | 78 #define SK_DECLARE_GLOBAL_MUTEX(name) SkBaseMutex name |
75 | 79 |
76 #endif | 80 #endif |
OLD | NEW |