aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/private/SkOncePtr.h
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@google.com>2015-09-09 07:10:42 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-09-09 07:10:42 -0700
commit2ac6793efc9b33f6104f9c39810bee5714bdc208 (patch)
tree9d7e8e1e89d3fae55e7f6eabc9139fa28989d561 /include/private/SkOncePtr.h
parent62fb1ba1786863e545c89839b5706ad5151cec15 (diff)
Revert of Port uses of SkLazyPtr to SkOncePtr. (patchset #7 id:110001 of https://codereview.chromium.org/1322933005/ )
Reason for revert: Breaks Chrome roll. obj/skia/ext/skia_chrome.skia_memory_dump_provider.o does not have -I include/private on its include path, but transitively includes SkMessageBus.h. Original issue's description: > Port uses of SkLazyPtr to SkOncePtr. > > This gives SkOncePtr a non-trivial destructor that uses std::default_delete > by default. This is overrideable, as seen in SkColorTable. > > SK_DECLARE_STATIC_ONCE_PTR still just leaves its pointers hanging at EOP. > > BUG=skia: > > No public API changes. > TBR=reed@google.com > > Committed: https://skia.googlesource.com/skia/+/a1254acdb344174e761f5061c820559dab64a74c TBR=herb@google.com,mtklein@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1334523002
Diffstat (limited to 'include/private/SkOncePtr.h')
-rw-r--r--include/private/SkOncePtr.h23
1 files changed, 11 insertions, 12 deletions
diff --git a/include/private/SkOncePtr.h b/include/private/SkOncePtr.h
index 40bea1a4c3..9af204bcb2 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 @@ public:
}
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 @@ inline void SkOnce(SkOnceFlag* once, const F& f) {
// Implementation details below here! No peeking!
template <typename T>
-class SkBaseOncePtr {
+class SkStaticOnce {
public:
template <typename F>
T* get(const F& f) const {