Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: src/ports/SkMutex_win.h

Issue 129533002: Fix TODO in SkMutex_win.h to prevent accidental copying. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 12 matching lines...) Expand all
23 # 23 #
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 // TODO: this exists because SK_DECLARE_STATIC_ONCE in methods is currently
34 // relying on a compiler bug which allows the '=' to work.
35 // All use of SK_DECLARE_STATIC_ONCE in methods is unsafe, and must be removed.
36 // To find these cases, make SkMutex's copy and assignement private directly.
37 class SkNoncopyableMutex {
38 public:
39 SkNoncopyableMutex() { }
40
41 private:
42 SkNoncopyableMutex(const SkNoncopyableMutex&);
43 SkNoncopyableMutex& operator=(const SkNoncopyableMutex&);
44 };
45
46 // On Windows, SkBaseMutex and SkMutex are the same thing, 33 // On Windows, SkBaseMutex and SkMutex are the same thing,
47 // we can't easily get rid of static initializers. 34 // we can't easily get rid of static initializers.
48 class SkMutex : SkNoncopyableMutex { 35 class SkMutex {
49 public: 36 public:
50 SkMutex() { 37 SkMutex() {
51 InitializeCriticalSection(&fStorage); 38 InitializeCriticalSection(&fStorage);
52 } 39 }
53 40
54 ~SkMutex() { 41 ~SkMutex() {
55 DeleteCriticalSection(&fStorage); 42 DeleteCriticalSection(&fStorage);
56 } 43 }
57 44
58 void acquire() { 45 void acquire() {
59 EnterCriticalSection(&fStorage); 46 EnterCriticalSection(&fStorage);
60 } 47 }
61 48
62 void release() { 49 void release() {
63 LeaveCriticalSection(&fStorage); 50 LeaveCriticalSection(&fStorage);
64 } 51 }
65 52
66 private: 53 private:
54 SkMutex(const SkMutex&);
55 SkMutex& operator=(const SkMutex&);
56
67 CRITICAL_SECTION fStorage; 57 CRITICAL_SECTION fStorage;
68 }; 58 };
69 59
70 typedef SkMutex SkBaseMutex; 60 typedef SkMutex SkBaseMutex;
71 61
72 // Windows currently provides no documented means of POD initializing a CRITICAL _SECTION. 62 // Windows currently provides no documented means of POD initializing a CRITICAL _SECTION.
73 #define SK_DECLARE_STATIC_MUTEX(name) static SkBaseMutex name 63 #define SK_DECLARE_STATIC_MUTEX(name) static SkBaseMutex name
74 #define SK_DECLARE_GLOBAL_MUTEX(name) SkBaseMutex name 64 #define SK_DECLARE_GLOBAL_MUTEX(name) SkBaseMutex name
75 65
76 #endif 66 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698