OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
4 * | 3 * |
5 * 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 |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 | |
10 #ifndef SkRefCnt_DEFINED | 8 #ifndef SkRefCnt_DEFINED |
11 #define SkRefCnt_DEFINED | 9 #define SkRefCnt_DEFINED |
12 | 10 |
13 #include "SkAtomics.h" | 11 #include "SkAtomics.h" |
14 #include "SkTemplates.h" | 12 #include "SkTypes.h" |
15 | 13 |
16 /** \class SkRefCntBase | 14 /** \class SkRefCntBase |
17 | 15 |
18 SkRefCntBase is the base class for objects that may be shared by multiple | 16 SkRefCntBase is the base class for objects that may be shared by multiple |
19 objects. When an existing owner wants to share a reference, it calls ref(). | 17 objects. When an existing owner wants to share a reference, it calls ref(). |
20 When an owner wants to release its reference, it calls unref(). When the | 18 When an owner wants to release its reference, it calls unref(). When the |
21 shared object's reference count goes to zero as the result of an unref() | 19 shared object's reference count goes to zero as the result of an unref() |
22 call, its (virtual) destructor is called. It is an error for the | 20 call, its (virtual) destructor is called. It is an error for the |
23 destructor to be called explicitly (or via the object going out of scope on | 21 destructor to be called explicitly (or via the object going out of scope on |
24 the stack or calling delete) if getRefCnt() > 1. | 22 the stack or calling delete) if getRefCnt() > 1. |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 SkDELETE((const Derived*)this); | 238 SkDELETE((const Derived*)this); |
241 } | 239 } |
242 } | 240 } |
243 void deref() const { this->unref(); } | 241 void deref() const { this->unref(); } |
244 | 242 |
245 private: | 243 private: |
246 mutable int32_t fRefCnt; | 244 mutable int32_t fRefCnt; |
247 }; | 245 }; |
248 | 246 |
249 #endif | 247 #endif |
OLD | NEW |