diff options
author | Johnathan Corgan | 2012-04-04 16:03:10 -0700 |
---|---|---|
committer | Johnathan Corgan | 2012-04-04 16:03:10 -0700 |
commit | c787fb66bf3512b5cd4870ef74cd1e4d91802820 (patch) | |
tree | af70483f5ba8fb24bc07f92c2d5ec6b208d3663e /gruel/src/lib/pmt | |
parent | 512f64f7bc123fe3a6f2ae6cd788a0529b9fd8cf (diff) | |
parent | f88b8cf5508d3ba446cb94f800c56d34279cf91e (diff) | |
download | gnuradio-c787fb66bf3512b5cd4870ef74cd1e4d91802820.tar.gz gnuradio-c787fb66bf3512b5cd4870ef74cd1e4d91802820.tar.bz2 gnuradio-c787fb66bf3512b5cd4870ef74cd1e4d91802820.zip |
Merge branch 'master' into next
Diffstat (limited to 'gruel/src/lib/pmt')
-rw-r--r-- | gruel/src/lib/pmt/pmt.cc | 14 | ||||
-rw-r--r-- | gruel/src/lib/pmt/pmt_int.h | 9 |
2 files changed, 21 insertions, 2 deletions
diff --git a/gruel/src/lib/pmt/pmt.cc b/gruel/src/lib/pmt/pmt.cc index f9cf6b4bf..57b66b1a4 100644 --- a/gruel/src/lib/pmt/pmt.cc +++ b/gruel/src/lib/pmt/pmt.cc @@ -58,7 +58,7 @@ pmt_base::operator delete(void *p, size_t size) #endif void intrusive_ptr_add_ref(pmt_base* p) { ++(p->count_); } -void intrusive_ptr_release(pmt_base* p) { if (--(p->count_) == 0 ) delete p; } +void intrusive_ptr_release(pmt_base* p) { if (--(p->count_) == 0 ) p->deleter_(p); } pmt_base::~pmt_base() { @@ -1383,4 +1383,16 @@ pmt_dump_sizeof() printf("sizeof(pmt_uniform_vector) = %3zd\n", sizeof(pmt_uniform_vector)); } +/* + * ------------------------------------------------------------------------ + * advanced + * ------------------------------------------------------------------------ + */ + +void +pmt_set_deleter(pmt_t obj, boost::function<void(pmt_base *)> &deleter) +{ + obj->deleter_ = (deleter)? deleter : &pmt_base::default_deleter; +} + } /* namespace pmt */ diff --git a/gruel/src/lib/pmt/pmt_int.h b/gruel/src/lib/pmt/pmt_int.h index 3a5cd382b..745dbc666 100644 --- a/gruel/src/lib/pmt/pmt_int.h +++ b/gruel/src/lib/pmt/pmt_int.h @@ -38,8 +38,15 @@ namespace pmt { class GRUEL_API pmt_base : boost::noncopyable { mutable boost::detail::atomic_count count_; +public: + static void default_deleter(pmt_base *p){ + delete p; + } + + boost::function<void(pmt_base *)> deleter_; + protected: - pmt_base() : count_(0) {}; + pmt_base() : count_(0), deleter_(&pmt::pmt_base::default_deleter) {}; virtual ~pmt_base(); public: |