This patch changes pmt_t to use boost intrusive pointers.
Patch was modified to apply to new pmt location since the
original patch was created, and add missing include file.
Signed-off-by: Johnathan Corgan <jcorgan@corganenterprises.com>
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@11595
221aa14e-8319-0410-a670-
987f0aec2ac5
#ifndef INCLUDED_PMT_H
#define INCLUDED_PMT_H
#ifndef INCLUDED_PMT_H
#define INCLUDED_PMT_H
-#include <boost/shared_ptr.hpp>
+#include <boost/intrusive_ptr.hpp>
#include <boost/any.hpp>
#include <complex>
#include <string>
#include <boost/any.hpp>
#include <complex>
#include <string>
* \brief typedef for shared pointer (transparent reference counting).
* See http://www.boost.org/libs/smart_ptr/smart_ptr.htm
*/
* \brief typedef for shared pointer (transparent reference counting).
* See http://www.boost.org/libs/smart_ptr/smart_ptr.htm
*/
-typedef boost::shared_ptr<pmt_base> pmt_t;
+typedef boost::intrusive_ptr<pmt_base> pmt_t;
+extern void intrusive_ptr_add_ref(pmt_base*);
+extern void intrusive_ptr_release(pmt_base*);
class pmt_exception : public std::logic_error
{
class pmt_exception : public std::logic_error
{
+void intrusive_ptr_add_ref(pmt_base* p) { ++(p->count_); }
+void intrusive_ptr_release(pmt_base* p) { if (--(p->count_) == 0 ) delete p; }
#include <gruel/pmt.h>
#include <boost/utility.hpp>
#include <gruel/pmt.h>
#include <boost/utility.hpp>
+#include <boost/detail/atomic_count.hpp>
/*
* EVERYTHING IN THIS FILE IS PRIVATE TO THE IMPLEMENTATION!
/*
* EVERYTHING IN THIS FILE IS PRIVATE TO THE IMPLEMENTATION!
namespace pmt {
class pmt_base : boost::noncopyable {
namespace pmt {
class pmt_base : boost::noncopyable {
+ mutable boost::detail::atomic_count count_;
+
+ pmt_base() : count_(0) {};
virtual ~pmt_base();
public:
virtual ~pmt_base();
public:
virtual bool is_c32vector() const { return false; }
virtual bool is_c64vector() const { return false; }
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);
# if (PMT_LOCAL_ALLOCATOR)
void *operator new(size_t);
void operator delete(void *, size_t);