diff options
author | Josh Blum <josh@joshknows.com> | 2011-02-09 19:56:45 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-02-09 19:56:45 -0800 |
commit | aa73e29d507f1523c17cf625dbd9c68f5a7d3787 (patch) | |
tree | e208a28773b0f6b4780bd24d1d1d6c085e69f1fa /host/lib/usrp/usrp2 | |
parent | a72e29ca1de5b484bedcb1cfa8be6cd2216dc54e (diff) | |
download | uhd-aa73e29d507f1523c17cf625dbd9c68f5a7d3787.tar.gz uhd-aa73e29d507f1523c17cf625dbd9c68f5a7d3787.tar.bz2 uhd-aa73e29d507f1523c17cf625dbd9c68f5a7d3787.zip |
uhd: tweaks to vrt pkt handler and usrp2 fc monitor
pkt handler, only resize once per call to send/recv (not per fragment)
fc monitor, code tweaks, check ready before touching time wait stuff (faster)
Diffstat (limited to 'host/lib/usrp/usrp2')
-rw-r--r-- | host/lib/usrp/usrp2/io_impl.cpp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/host/lib/usrp/usrp2/io_impl.cpp b/host/lib/usrp/usrp2/io_impl.cpp index 0376ebdae..d09ce1871 100644 --- a/host/lib/usrp/usrp2/io_impl.cpp +++ b/host/lib/usrp/usrp2/io_impl.cpp @@ -32,6 +32,18 @@ using namespace uhd; using namespace uhd::usrp; using namespace uhd::transport; namespace asio = boost::asio; +namespace pt = boost::posix_time; + +/*********************************************************************** + * helpers + **********************************************************************/ +static UHD_INLINE pt::time_duration to_time_dur(double timeout){ + return pt::microseconds(long(timeout*1e6)); +} + +static UHD_INLINE double from_time_dur(const pt::time_duration &time_dur){ + return 1e-6*time_dur.total_microseconds(); +} /*********************************************************************** * constants @@ -61,6 +73,7 @@ public: _last_seq_out = 0; _last_seq_ack = 0; _max_seqs_out = max_seqs_out; + _ready_fcn = boost::bind(&flow_control_monitor::ready, this); } /*! @@ -73,11 +86,8 @@ public: boost::this_thread::disable_interruption di; //disable because the wait can throw boost::unique_lock<boost::mutex> lock(_fc_mutex); _last_seq_out = seq; - return _fc_cond.timed_wait( - lock, - boost::posix_time::microseconds(long(timeout*1e6)), - boost::bind(&flow_control_monitor::ready, this) - ); + if (this->ready()) return true; + return _fc_cond.timed_wait(lock, to_time_dur(timeout), _ready_fcn); } /*! @@ -99,6 +109,7 @@ private: boost::mutex _fc_mutex; boost::condition _fc_cond; seq_type _last_seq_out, _last_seq_ack, _max_seqs_out; + boost::function<bool(void)> _ready_fcn; }; /*********************************************************************** @@ -318,14 +329,6 @@ size_t usrp2_impl::send( /*********************************************************************** * Alignment logic on receive **********************************************************************/ -static UHD_INLINE boost::posix_time::time_duration to_time_dur(double timeout){ - return boost::posix_time::microseconds(long(timeout*1e6)); -} - -static UHD_INLINE double from_time_dur(const boost::posix_time::time_duration &time_dur){ - return 1e-6*time_dur.total_microseconds(); -} - static UHD_INLINE time_spec_t extract_time_spec( const vrt::if_packet_info_t &packet_info ){ |