[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r11442 - gnuradio/trunk/pmt/src/lib
From: |
eb |
Subject: |
[Commit-gnuradio] r11442 - gnuradio/trunk/pmt/src/lib |
Date: |
Tue, 14 Jul 2009 19:33:49 -0600 (MDT) |
Author: eb
Date: 2009-07-14 19:33:49 -0600 (Tue, 14 Jul 2009)
New Revision: 11442
Modified:
gnuradio/trunk/pmt/src/lib/pmt.cc
gnuradio/trunk/pmt/src/lib/pmt.h
gnuradio/trunk/pmt/src/lib/pmt_int.h
Log:
pmt performance improvement: Switch from shared_ptr to intrusive_ptr
for pmt_t (c1258 from Stefan Br?\195?\188ns).
Modified: gnuradio/trunk/pmt/src/lib/pmt.cc
===================================================================
--- gnuradio/trunk/pmt/src/lib/pmt.cc 2009-07-15 01:32:01 UTC (rev 11441)
+++ gnuradio/trunk/pmt/src/lib/pmt.cc 2009-07-15 01:33:49 UTC (rev 11442)
@@ -54,6 +54,8 @@
#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()
{
Modified: gnuradio/trunk/pmt/src/lib/pmt.h
===================================================================
--- gnuradio/trunk/pmt/src/lib/pmt.h 2009-07-15 01:32:01 UTC (rev 11441)
+++ gnuradio/trunk/pmt/src/lib/pmt.h 2009-07-15 01:33:49 UTC (rev 11442)
@@ -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>
@@ -48,8 +48,10 @@
* \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
{
Modified: gnuradio/trunk/pmt/src/lib/pmt_int.h
===================================================================
--- gnuradio/trunk/pmt/src/lib/pmt_int.h 2009-07-15 01:32:01 UTC (rev
11441)
+++ gnuradio/trunk/pmt/src/lib/pmt_int.h 2009-07-15 01:33:49 UTC (rev
11442)
@@ -34,8 +34,10 @@
#define PMT_LOCAL_ALLOCATOR 0 // define to 0 or 1
class pmt_base : boost::noncopyable {
+ mutable boost::detail::atomic_count count_;
+
protected:
- pmt_base(){};
+ pmt_base() : count_(0) {};
virtual ~pmt_base();
public:
@@ -65,6 +67,9 @@
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);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r11442 - gnuradio/trunk/pmt/src/lib,
eb <=