summaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-05-16 12:08:23 -0700
committerJosh Blum <josh@joshknows.com>2011-05-16 12:08:23 -0700
commit22097e81dc54c895ed411c74c1829721e3a1ce5e (patch)
tree8cc9ca6d8bb0432b9562fc19636eca3421b21100 /host/include
parent13be023531fa1be8d43b999c3ea5ab477f101fdc (diff)
parentea5ce50a465e714c63196f52df97fb3e927e701c (diff)
downloaduhd-22097e81dc54c895ed411c74c1829721e3a1ce5e.tar.gz
uhd-22097e81dc54c895ed411c74c1829721e3a1ce5e.tar.bz2
uhd-22097e81dc54c895ed411c74c1829721e3a1ce5e.zip
Merge branch 'master' into release_work
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/transport/zero_copy.hpp31
-rw-r--r--host/include/uhd/utils/log.hpp2
2 files changed, 30 insertions, 3 deletions
diff --git a/host/include/uhd/transport/zero_copy.hpp b/host/include/uhd/transport/zero_copy.hpp
index 092028d09..f80c738aa 100644
--- a/host/include/uhd/transport/zero_copy.hpp
+++ b/host/include/uhd/transport/zero_copy.hpp
@@ -21,9 +21,16 @@
#include <uhd/config.hpp>
#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp>
+#include <boost/intrusive_ptr.hpp>
namespace uhd{ namespace transport{
+ //! Create smart pointer to a reusable managed buffer
+ template <typename T> UHD_INLINE boost::intrusive_ptr<T> make_managed_buffer(T *p){
+ p->_ref_count = 1; //reset the count to 1 reference
+ return boost::intrusive_ptr<T>(p, false);
+ }
+
/*!
* A managed receive buffer:
* Contains a reference to transport-managed memory,
@@ -31,7 +38,7 @@ namespace uhd{ namespace transport{
*/
class UHD_API managed_recv_buffer{
public:
- typedef boost::shared_ptr<managed_recv_buffer> sptr;
+ typedef boost::intrusive_ptr<managed_recv_buffer> sptr;
/*!
* Signal to the transport that we are done with the buffer.
@@ -59,8 +66,18 @@ namespace uhd{ namespace transport{
private:
virtual const void *get_buff(void) const = 0;
virtual size_t get_size(void) const = 0;
+
+ public: int _ref_count;
};
+ UHD_INLINE void intrusive_ptr_add_ref(managed_recv_buffer *p){
+ ++(p->_ref_count);
+ }
+
+ UHD_INLINE void intrusive_ptr_release(managed_recv_buffer *p){
+ if (--(p->_ref_count) == 0) p->release();
+ }
+
/*!
* A managed send buffer:
* Contains a reference to transport-managed memory,
@@ -68,7 +85,7 @@ namespace uhd{ namespace transport{
*/
class UHD_API managed_send_buffer{
public:
- typedef boost::shared_ptr<managed_send_buffer> sptr;
+ typedef boost::intrusive_ptr<managed_send_buffer> sptr;
/*!
* Signal to the transport that we are done with the buffer.
@@ -97,8 +114,18 @@ namespace uhd{ namespace transport{
private:
virtual void *get_buff(void) const = 0;
virtual size_t get_size(void) const = 0;
+
+ public: int _ref_count;
};
+ UHD_INLINE void intrusive_ptr_add_ref(managed_send_buffer *p){
+ ++(p->_ref_count);
+ }
+
+ UHD_INLINE void intrusive_ptr_release(managed_send_buffer *p){
+ if (--(p->_ref_count) == 0) p->commit(0);
+ }
+
/*!
* A zero-copy interface for transport objects.
* Provides a way to get send and receive buffers
diff --git a/host/include/uhd/utils/log.hpp b/host/include/uhd/utils/log.hpp
index 8d8f42fd0..7f83fd2a9 100644
--- a/host/include/uhd/utils/log.hpp
+++ b/host/include/uhd/utils/log.hpp
@@ -38,7 +38,7 @@
* (in other words, as often or less often than the current log level)
* are recorded into the log file. All other messages are sent to null.
*
- * The default log level is "regular", but can be overridden:
+ * The default log level is "never", but can be overridden:
* - at compile time by setting the pre-processor define UHD_LOG_LEVEL.
* - at runtime by setting the environment variable UHD_LOG_LEVEL.
*