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

Side by Side Diff: include/core/SkWeakRefCnt.h

Issue 25716003: Make it explicit that some validate methods are debug only ... (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 2 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 | « include/core/SkRefCnt.h ('k') | include/gpu/GrTexture.h » ('j') | 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 2012 Google Inc. 2 * Copyright 2012 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 SkWeakRefCnt_DEFINED 8 #ifndef SkWeakRefCnt_DEFINED
9 #define SkWeakRefCnt_DEFINED 9 #define SkWeakRefCnt_DEFINED
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 #ifdef SK_DEBUG 66 #ifdef SK_DEBUG
67 SkASSERT(fWeakCnt == 1); 67 SkASSERT(fWeakCnt == 1);
68 fWeakCnt = 0; 68 fWeakCnt = 0;
69 #endif 69 #endif
70 } 70 }
71 71
72 /** Return the weak reference count. 72 /** Return the weak reference count.
73 */ 73 */
74 int32_t getWeakCnt() const { return fWeakCnt; } 74 int32_t getWeakCnt() const { return fWeakCnt; }
75 75
76 #ifdef SK_DEBUG
76 void validate() const { 77 void validate() const {
77 SkRefCnt::validate(); 78 this->INHERITED::validate();
78 SkASSERT(fWeakCnt > 0); 79 SkASSERT(fWeakCnt > 0);
79 } 80 }
81 #endif
80 82
81 /** Creates a strong reference from a weak reference, if possible. The 83 /** Creates a strong reference from a weak reference, if possible. The
82 caller must already be an owner. If try_ref() returns true the owner 84 caller must already be an owner. If try_ref() returns true the owner
83 is in posession of an additional strong reference. Both the original 85 is in posession of an additional strong reference. Both the original
84 reference and new reference must be properly unreferenced. If try_ref() 86 reference and new reference must be properly unreferenced. If try_ref()
85 returns false, no strong reference could be created and the owner's 87 returns false, no strong reference could be created and the owner's
86 reference is in the same state as before the call. 88 reference is in the same state as before the call.
87 */ 89 */
88 bool SK_WARN_UNUSED_RESULT try_ref() const { 90 bool SK_WARN_UNUSED_RESULT try_ref() const {
89 if (sk_atomic_conditional_inc(&fRefCnt) != 0) { 91 if (sk_atomic_conditional_inc(&fRefCnt) != 0) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 weak_unref(); 152 weak_unref();
151 } 153 }
152 154
153 /* Invariant: fWeakCnt = #weak + (fRefCnt > 0 ? 1 : 0) */ 155 /* Invariant: fWeakCnt = #weak + (fRefCnt > 0 ? 1 : 0) */
154 mutable int32_t fWeakCnt; 156 mutable int32_t fWeakCnt;
155 157
156 typedef SkRefCnt INHERITED; 158 typedef SkRefCnt INHERITED;
157 }; 159 };
158 160
159 #endif 161 #endif
OLDNEW
« no previous file with comments | « include/core/SkRefCnt.h ('k') | include/gpu/GrTexture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698