summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/pmt/pmt.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-runtime/lib/pmt/pmt.cc')
-rw-r--r--gnuradio-runtime/lib/pmt/pmt.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/gnuradio-runtime/lib/pmt/pmt.cc b/gnuradio-runtime/lib/pmt/pmt.cc
index e09452e60e..da2a7e5cc2 100644
--- a/gnuradio-runtime/lib/pmt/pmt.cc
+++ b/gnuradio-runtime/lib/pmt/pmt.cc
@@ -63,9 +63,18 @@ 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_add_ref(pmt_base* p)
+{
+ p->refcount_.fetch_add(1, boost::memory_order_relaxed);
+}
+void intrusive_ptr_release(pmt_base* p) {
+ if (p->refcount_.fetch_sub(1, boost::memory_order_release) == 1) {
+ boost::atomic_thread_fence(boost::memory_order_acquire);
+ delete p;
+ }
+}
+
pmt_base::~pmt_base()
{
// nop -- out of line virtual destructor