=== modified file 'pmt/src/lib/pmt.cc' --- pmt/src/lib/pmt.cc 2009-01-30 14:40:12 +0000 +++ pmt/src/lib/pmt.cc 2009-01-30 14:41:35 +0000 @@ -54,6 +54,8 @@ #endif +void intrusive_ptr_add_ref(pmt_base* p) { ++(p->count_); } +void intrusive_ptr_release(pmt_base* p) { if (--(p->count_) == 0 ) delete p; } pmt_base::~pmt_base() { === modified file 'pmt/src/lib/pmt.h' --- pmt/src/lib/pmt.h 2009-01-30 14:40:12 +0000 +++ pmt/src/lib/pmt.h 2009-01-30 14:41:35 +0000 @@ -23,7 +23,7 @@ #ifndef INCLUDED_PMT_H #define INCLUDED_PMT_H -#include +#include #include #include #include @@ -48,8 +48,10 @@ * \brief typedef for shared pointer (transparent reference counting). * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm */ -typedef boost::shared_ptr pmt_t; +typedef boost::intrusive_ptr pmt_t; +extern void intrusive_ptr_add_ref(pmt_base*); +extern void intrusive_ptr_release(pmt_base*); class pmt_exception : public std::logic_error { === modified file 'pmt/src/lib/pmt_int.h' --- pmt/src/lib/pmt_int.h 2009-01-30 14:40:12 +0000 +++ pmt/src/lib/pmt_int.h 2009-01-30 14:41:35 +0000 @@ -34,8 +34,10 @@ #define PMT_LOCAL_ALLOCATOR 0 // define to 0 or 1 class pmt_base : boost::noncopyable { + mutable boost::detail::atomic_count count_; + protected: - pmt_base(){}; + pmt_base() : count_(0) {}; virtual ~pmt_base(); public: @@ -65,6 +67,9 @@ virtual bool is_c32vector() const { return false; } virtual bool is_c64vector() const { return false; } + friend void intrusive_ptr_add_ref(pmt_base* p); + friend void intrusive_ptr_release(pmt_base* p); + # if (PMT_LOCAL_ALLOCATOR) void *operator new(size_t); void operator delete(void *, size_t);