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

Unified Diff: include/private/SkOncePtr.h

Issue 1334523002: Revert of Port uses of SkLazyPtr to SkOncePtr. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkTypeface.h ('k') | src/core/SkBigPicture.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/private/SkOncePtr.h
diff --git a/include/private/SkOncePtr.h b/include/private/SkOncePtr.h
index 40bea1a4c3b9cf462d69077748134d93d15ab3a3..9af204bcb29381d97f8444165d10267ce79a460b 100644
--- a/include/private/SkOncePtr.h
+++ b/include/private/SkOncePtr.h
@@ -9,23 +9,22 @@
#define SkOncePtr_DEFINED
#include "SkAtomics.h"
-#include "SkUniquePtr.h"
-template <typename T> class SkBaseOncePtr;
+template <typename T> class SkStaticOnce;
// Use this to create a global static pointer that's intialized exactly once when you call get().
-#define SK_DECLARE_STATIC_ONCE_PTR(type, name) namespace {} static SkBaseOncePtr<type> name
+#define SK_DECLARE_STATIC_ONCE_PTR(type, name) namespace {} static SkStaticOnce<type> name
// Use this for a local or member pointer that's initialized exactly once when you call get().
-template <typename T, typename Delete = skstd::default_delete<T>>
+template <typename T>
class SkOncePtr : SkNoncopyable {
public:
SkOncePtr() { sk_bzero(this, sizeof(*this)); }
- ~SkOncePtr() {
- if (T* ptr = (T*)*this) {
- Delete()(ptr);
- }
- }
+
+ // SkOncePtr does not have a destructor and does not clean up the pointer. But you may, e.g.
+ // delete (T*)fOncePtr;
+ // SkSafeUnref((T*)fOncePtr);
+ // etc.
template <typename F>
T* get(const F& f) const {
@@ -37,11 +36,11 @@
}
private:
- SkBaseOncePtr<T> fOnce;
+ SkStaticOnce<T> fOnce;
};
/* TODO(mtklein): in next CL
-typedef SkBaseOncePtr<void> SkOnceFlag;
+typedef SkStaticOnce<void> SkOnceFlag;
#define SK_DECLARE_STATIC_ONCE(name) namespace {} static SkOnceFlag name
template <typename F>
@@ -53,7 +52,7 @@
// Implementation details below here! No peeking!
template <typename T>
-class SkBaseOncePtr {
+class SkStaticOnce {
public:
template <typename F>
T* get(const F& f) const {
« no previous file with comments | « include/core/SkTypeface.h ('k') | src/core/SkBigPicture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698