Merged branch 'msg-passing' from http://gnuradio.org/git/eb.git
authorJohnathan Corgan <jcorgan@corganenterprises.com>
Sat, 15 Aug 2009 16:28:54 +0000 (09:28 -0700)
committerJohnathan Corgan <jcorgan@corganenterprises.com>
Sat, 15 Aug 2009 16:28:54 +0000 (09:28 -0700)
This is work in progress on the message passing implementation.

Passes distcheck.

Signed-off-by: Johnathan Corgan <jcorgan@corganenterprises.com>
gruel/src/include/gruel/pmt.h
gruel/src/lib/pmt/pmt.cc
gruel/src/lib/pmt/pmt_int.h

index ed337a885a3ae392197fd123ed3fcedccebb3e77..2403593017f52ea79265e6a632f935d932465a28 100644 (file)
@@ -23,7 +23,7 @@
 #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>
@@ -50,8 +50,10 @@ class pmt_base;
  * \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
 {
index 20dc4e42c403014b37d0f36fcbebd9a2889dea32..f0e3c30a266f630a78252e0c4a2a35f2cfb7a918 100644 (file)
@@ -56,6 +56,8 @@ 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; }
 
 pmt_base::~pmt_base()
 {
index ed47249b12a5e192698f25a5e0b2f451d26abf47..7581845f825df373a65951c7d8241e8b60e1f5f9 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <gruel/pmt.h>
 #include <boost/utility.hpp>
+#include <boost/detail/atomic_count.hpp>
 
 /*
  * EVERYTHING IN THIS FILE IS PRIVATE TO THE IMPLEMENTATION!
 namespace pmt {
 
 class pmt_base : boost::noncopyable {
+  mutable boost::detail::atomic_count count_;
+
 protected:
-  pmt_base(){};
+  pmt_base() : count_(0) {};
   virtual ~pmt_base();
 
 public:
@@ -67,6 +70,9 @@ public:
   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);