commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 15/148: virtual destructor and shared ptr f


From: git
Subject: [Commit-gnuradio] [gnuradio] 15/148: virtual destructor and shared ptr for transport
Date: Mon, 15 Aug 2016 00:47:20 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

nwest pushed a commit to annotated tag old_usrp_devel_udp
in repository gnuradio.

commit 3061f3e9c7aa50ab20b90e4679217b9b658c0f4e
Author: Josh Blum <address@hidden>
Date:   Tue Nov 3 22:59:53 2009 -0800

    virtual destructor and shared ptr for transport
---
 usrp2/host/lib/transport.cc  | 3 ++-
 usrp2/host/lib/transport.h   | 3 ++-
 usrp2/host/lib/usrp2.cc      | 3 ++-
 usrp2/host/lib/usrp2_impl.cc | 2 +-
 usrp2/host/lib/usrp2_impl.h  | 4 ++--
 5 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/usrp2/host/lib/transport.cc b/usrp2/host/lib/transport.cc
index 325e829..4c180f9 100644
--- a/usrp2/host/lib/transport.cc
+++ b/usrp2/host/lib/transport.cc
@@ -22,6 +22,7 @@
 
 #include "transport.h"
 #include <stdexcept>
+#include <cstdio>
 
 static void nop_cb(void *buff, size_t len){
     //NOP
@@ -45,6 +46,7 @@ void usrp2::transport::start(){
     if (d_running){
         throw std::runtime_error("usrp2::transport for" + d_type_str + " 
already started\n");
     }
+    d_running = true;
     d_thread = new boost::thread(boost::bind(&usrp2::transport::run, this));
 }
 
@@ -58,7 +60,6 @@ void usrp2::transport::stop(){
 
 void usrp2::transport::run(){
     init();
-    d_running = true;
     void *buff;
     while (d_running){
         try{
diff --git a/usrp2/host/lib/transport.h b/usrp2/host/lib/transport.h
index c6a42f8..0b6198a 100644
--- a/usrp2/host/lib/transport.h
+++ b/usrp2/host/lib/transport.h
@@ -27,6 +27,7 @@ namespace usrp2 {
   class transport {
   public:
     typedef boost::function<void(void*, size_t)> callback_t;
+    typedef boost::shared_ptr<transport> sptr;
   private:
     std::string              d_type_str;
     volatile bool            d_running;
@@ -40,7 +41,7 @@ namespace usrp2 {
      * \param type_str a descriptive string
      */
     transport(const std::string &type_str);
-    ~transport();
+    virtual ~transport();
     /*!
      * \brief Set the callback
      * \param cb the callback created by boost::bind
diff --git a/usrp2/host/lib/usrp2.cc b/usrp2/host/lib/usrp2.cc
index 0ed854a..b34e0b1 100644
--- a/usrp2/host/lib/usrp2.cc
+++ b/usrp2/host/lib/usrp2.cc
@@ -230,7 +230,8 @@ namespace usrp2 {
   // Private constructor.  Sole function is to create an impl.
   usrp2::usrp2(const std::string &ifc, props *p, size_t rx_bufsize)
   {
-    d_impl = std::auto_ptr<impl>(new usrp2::impl(ifc, p, rx_bufsize, new 
eth_ctrl_transport(ifc, p)));
+    transport::sptr ctrl_transport(new eth_ctrl_transport(ifc, p));
+    d_impl = std::auto_ptr<impl>(new usrp2::impl(ifc, p, rx_bufsize, 
ctrl_transport));
   }
   
   // Public class destructor.  d_impl will auto-delete.
diff --git a/usrp2/host/lib/usrp2_impl.cc b/usrp2/host/lib/usrp2_impl.cc
index e9bb4b8..ec9a24c 100644
--- a/usrp2/host/lib/usrp2_impl.cc
+++ b/usrp2/host/lib/usrp2_impl.cc
@@ -129,7 +129,7 @@ namespace usrp2 {
   }
 
 
-  usrp2::impl::impl(const std::string &ifc, props *p, size_t rx_bufsize, 
transport *ctrl_transport)
+  usrp2::impl::impl(const std::string &ifc, props *p, size_t rx_bufsize, 
transport::sptr ctrl_transport)
     : d_eth_data(new eth_buffer(rx_bufsize)),
       d_eth_ctrl(new ethernet()),
       d_pf_data(0), 
diff --git a/usrp2/host/lib/usrp2_impl.h b/usrp2/host/lib/usrp2_impl.h
index 50cb78a..8702705 100644
--- a/usrp2/host/lib/usrp2_impl.h
+++ b/usrp2/host/lib/usrp2_impl.h
@@ -132,10 +132,10 @@ namespace usrp2 {
     void stop_data_thread();
     void run_data_thread();
 
-    transport *d_ctrl_transport;
+    transport::sptr d_ctrl_transport;
 
   public:
-    impl(const std::string &ifc, props *p, size_t rx_bufsize, transport 
*ctrl_transport);
+    impl(const std::string &ifc, props *p, size_t rx_bufsize, transport::sptr 
ctrl_transport);
     ~impl();
 
     std::string mac_addr() const { return d_addr; } // FIXME: convert from 
u2_mac_addr_t



reply via email to

[Prev in Thread] Current Thread [Next in Thread]