diff options
| author | Glenn Glazer <coyot@lindenlab.com> | 2016-04-07 12:10:13 -0700 |
|---|---|---|
| committer | Glenn Glazer <coyot@lindenlab.com> | 2016-04-07 12:10:13 -0700 |
| commit | 369cefd5b3f2f52ae0dd203fcd45a4618f74b0f3 (patch) | |
| tree | 941d27a32099abaf71bae8a2865002e2b25a3512 /indra/llcorehttp/_refcounted.h | |
| parent | 0494a502aafac73800352dc26c4eb3a27b02a8ce (diff) | |
| parent | 18928ea6c6f2830a0d45ec412c915eceff1b76b0 (diff) | |
pull from viewer-release
Diffstat (limited to 'indra/llcorehttp/_refcounted.h')
| -rwxr-xr-x | indra/llcorehttp/_refcounted.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/indra/llcorehttp/_refcounted.h b/indra/llcorehttp/_refcounted.h index 402e725152..7f713f2298 100755 --- a/indra/llcorehttp/_refcounted.h +++ b/indra/llcorehttp/_refcounted.h @@ -32,6 +32,7 @@ #include "fix_macros.h" #include <boost/thread.hpp> +#include <boost/intrusive_ptr.hpp> #include "llapr.h" @@ -120,7 +121,36 @@ inline void RefCounted::destroySelf() delete this; } +/** + * boost::intrusive_ptr may be used to manage RefCounted classes. + * Unfortunately RefCounted and boost::intrusive_ptr use different conventions + * for the initial refcount value. To avoid leaky (immortal) objects, you + * should really construct boost::intrusive_ptr<RefCounted*>(rawptr, false). + * IntrusivePtr<T> encapsulates that for you. + */ +template <typename T> +struct IntrusivePtr: public boost::intrusive_ptr<T> +{ + IntrusivePtr(): + boost::intrusive_ptr<T>() + {} + IntrusivePtr(T* p): + boost::intrusive_ptr<T>(p, false) + {} +}; + +inline void intrusive_ptr_add_ref(RefCounted* p) +{ + p->addRef(); +} + +inline void intrusive_ptr_release(RefCounted* p) +{ + p->release(); +} + } // end namespace LLCoreInt + #endif // LLCOREINT__REFCOUNTED_H_ |
