summaryrefslogtreecommitdiff
path: root/node/SharedPtr.hpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-11-23 10:46:52 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-11-23 10:46:52 -0800
commita18336fa1899a9f53b161a60e766695007c49a7b (patch)
treef464c0475ea49e3714df86d69508644adcf2e98a /node/SharedPtr.hpp
parent1e4a40e77205b028d799f7112127f3f2f107117e (diff)
parent764dd1c3d94527c0870a913ac314b3b17eaea282 (diff)
downloadinfinitytier-a18336fa1899a9f53b161a60e766695007c49a7b.tar.gz
infinitytier-a18336fa1899a9f53b161a60e766695007c49a7b.zip
MERGE current "dev" into "netcon" -- should not affect netcon itself but will retest -- brings ZeroTier core up to 1.1.0
Diffstat (limited to 'node/SharedPtr.hpp')
-rw-r--r--node/SharedPtr.hpp33
1 files changed, 19 insertions, 14 deletions
diff --git a/node/SharedPtr.hpp b/node/SharedPtr.hpp
index 4ecfa818..289c499f 100644
--- a/node/SharedPtr.hpp
+++ b/node/SharedPtr.hpp
@@ -64,20 +64,6 @@ public:
++obj->__refCount;
}
- SharedPtr(T *obj,bool runAwayFromZombies)
- throw() :
- _ptr(obj)
- {
- // HACK: this is used in "handlers" to take ownership of naked pointers,
- // an ugly pattern that really ought to be factored out.
- if (runAwayFromZombies) {
- if ((int)(++obj->__refCount) < 2) {
- --obj->__refCount;
- _ptr = (T *)0;
- }
- } else ++obj->__refCount;
- }
-
SharedPtr(const SharedPtr &sp)
throw() :
_ptr(sp._getAndInc())
@@ -105,6 +91,25 @@ public:
return *this;
}
+ /**
+ * Set to a naked pointer and increment its reference count
+ *
+ * This assumes this SharedPtr is NULL and that ptr is not a 'zombie.' No
+ * checks are performed.
+ *
+ * @param ptr Naked pointer to assign
+ */
+ inline void setToUnsafe(T *ptr)
+ {
+ ++ptr->__refCount;
+ _ptr = ptr;
+ }
+
+ /**
+ * Swap with another pointer 'for free' without ref count overhead
+ *
+ * @param with Pointer to swap with
+ */
inline void swap(SharedPtr &with)
throw()
{