summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-runtime/lib')
-rw-r--r--gnuradio-runtime/lib/pmt/pmt.cc13
-rw-r--r--gnuradio-runtime/lib/pmt/pmt_int.h7
2 files changed, 15 insertions, 5 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
diff --git a/gnuradio-runtime/lib/pmt/pmt_int.h b/gnuradio-runtime/lib/pmt/pmt_int.h
index 49bde52063..f06f507944 100644
--- a/gnuradio-runtime/lib/pmt/pmt_int.h
+++ b/gnuradio-runtime/lib/pmt/pmt_int.h
@@ -24,7 +24,8 @@
#include <pmt/pmt.h>
#include <boost/utility.hpp>
-#include <boost/detail/atomic_count.hpp>
+#include <boost/version.hpp>
+#include <boost/atomic.hpp>
/*
* EVERYTHING IN THIS FILE IS PRIVATE TO THE IMPLEMENTATION!
@@ -36,10 +37,10 @@
namespace pmt {
class PMT_API pmt_base : boost::noncopyable {
- mutable boost::detail::atomic_count count_;
+ mutable boost::atomic<int> refcount_;
protected:
- pmt_base() : count_(0) {};
+ pmt_base() : refcount_(0) {};
virtual ~pmt_base();
public: