[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 09/148: Refactored timeout handling
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 09/148: Refactored timeout handling |
Date: |
Mon, 15 Aug 2016 00:47:19 +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 541b4a46474e398656e0a5e36c1ebe7dc06ea2ff
Author: Johnathan Corgan <address@hidden>
Date: Sat Oct 31 06:51:50 2009 -0700
Refactored timeout handling
---
gruel/src/include/gruel/thread.h | 6 +++++-
gruel/src/lib/Makefile.am | 1 +
gruel/src/{include/gruel/thread.h => lib/thread.cc} | 20 ++++++++++----------
usrp2/host/lib/control.cc | 11 +++++------
usrp2/host/lib/usrp2_impl.cc | 2 +-
5 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/gruel/src/include/gruel/thread.h b/gruel/src/include/gruel/thread.h
index dc10d41..53423e2 100644
--- a/gruel/src/include/gruel/thread.h
+++ b/gruel/src/include/gruel/thread.h
@@ -29,7 +29,11 @@ namespace gruel {
typedef boost::mutex mutex;
typedef boost::unique_lock<boost::mutex> scoped_lock;
typedef boost::condition_variable condition_variable;
- typedef boost::posix_time::time_duration duration;
+
+ /*!
+ * Returns absolute time 'secs' into the future
+ */
+ boost::system_time get_new_timeout(double secs);
} /* namespace gruel */
diff --git a/gruel/src/lib/Makefile.am b/gruel/src/lib/Makefile.am
index b21f802..2b26017 100644
--- a/gruel/src/lib/Makefile.am
+++ b/gruel/src/lib/Makefile.am
@@ -45,6 +45,7 @@ MSG_LIB = msg/libmsg.la
libgruel_la_SOURCES = \
realtime.cc \
sys_pri.cc \
+ thread.cc \
thread_body_wrapper.cc \
thread_group.cc
diff --git a/gruel/src/include/gruel/thread.h b/gruel/src/lib/thread.cc
similarity index 69%
copy from gruel/src/include/gruel/thread.h
copy to gruel/src/lib/thread.cc
index dc10d41..b470aae 100644
--- a/gruel/src/include/gruel/thread.h
+++ b/gruel/src/lib/thread.cc
@@ -18,19 +18,19 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef INCLUDED_THREAD_H
-#define INCLUDED_THREAD_H
-#include <boost/thread.hpp>
-#include <boost/date_time/posix_time/posix_time.hpp>
+#include <gruel/thread.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
namespace gruel {
- typedef boost::mutex mutex;
- typedef boost::unique_lock<boost::mutex> scoped_lock;
- typedef boost::condition_variable condition_variable;
- typedef boost::posix_time::time_duration duration;
+ boost::system_time
+ get_new_timeout(double secs)
+ {
+ return boost::get_system_time() +
boost::posix_time::milliseconds(long(secs*1e3));
+ }
} /* namespace gruel */
-
-#endif /* INCLUDED_THREAD_H */
diff --git a/usrp2/host/lib/control.cc b/usrp2/host/lib/control.cc
index a5bbc56..4f3656b 100644
--- a/usrp2/host/lib/control.cc
+++ b/usrp2/host/lib/control.cc
@@ -44,13 +44,13 @@ namespace usrp2 {
pending_reply::wait_for_completion(double secs)
{
gruel::scoped_lock l(d_mutex);
- //gruel::duration td(0, 0, secs, 0);
+ boost::system_time to(gruel::get_new_timeout(secs));
- //if (!d_complete && !d_cond.timed_wait(l, td))
- // return 0; // timed out
+ while (!d_complete) {
+ if (!d_cond.timed_wait(l, to))
+ return 0; // timed out
+ }
- // DEBUG: don't implement timeout
- d_cond.wait(l);
return 1;
}
@@ -63,4 +63,3 @@ namespace usrp2 {
}
} // namespace usrp2
-
diff --git a/usrp2/host/lib/usrp2_impl.cc b/usrp2/host/lib/usrp2_impl.cc
index d3bf66c..905b74d 100644
--- a/usrp2/host/lib/usrp2_impl.cc
+++ b/usrp2/host/lib/usrp2_impl.cc
@@ -384,7 +384,7 @@ namespace usrp2 {
while (d_ctrl_running){
int ctrl_recv_len = d_eth_ctrl->read_packet_dont_block(buff,
sizeof(buff));
if (ctrl_recv_len >= 0) handle_control_packet(buff, ctrl_recv_len);
- boost::thread::sleep(boost::get_system_time() +
boost::posix_time::milliseconds(long(0.05*1e3))); //50ms timeout
+ boost::thread::sleep(gruel::get_new_timeout(0.05)); //50ms timeout
}
}
- [Commit-gnuradio] [gnuradio] annotated tag old_usrp_devel_udp created (now 90cd6f5), git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 01/148: Create separate raw Ethernet sockets and packet filters, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 03/148: Created a new thread for handling incoming control packets. TX/RX app is working with separate data and control ethernet types., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 10/148: Fix incorrect comparison, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 13/148: usrp2: remove install data hook for usrp2_socket_opener, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 04/148: Hosekeeping after control/data separation., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 05/148: Removed references to U2_ETHERTYPE and CONTROL_CHAN. Moved non-txrx-related apps in firmware broken by this., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 06/148: Common naming convention for control and data thread stuff., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 02/148: working a separate ctrl ethernet device into the code, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 07/148: using boost threads for control and data, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 09/148: Refactored timeout handling,
git <=
- [Commit-gnuradio] [gnuradio] 17/148: Began work on eth data transport class. Switched send in transport to use iovecs. Pass mac addr into eth transports rather than re-parsing., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 14/148: Created transport abstraction. Implemented ethernet transport for control. Control transport works in usrp impl. Needs a lot of cleanup., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 08/148: Removed omnithreads dependency from libusrp2, still debugging, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 18/148: Added a callback into the channel ring enqueue and dequeue. This will allow the deqeue caller to make an arbitrary call when its done with the data. Currently, the enqueue caller makes this callback a release_frames., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 15/148: virtual destructor and shared ptr for transport, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 28/148: Cleaned up the parse ethernet stuff. Made an official max_buffs method for the transport., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 20/148: Created sbuff class to house chunks of memory, their length, and possible callback for freeing/cleanup. Switched ring and transport to make use of the sbuff on receive., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 37/148: Fixes usrp2 firmware configure with mb-gcc on ubuntu 9.10/autoconf 2.64. Disables the regression test for fopen since stdio is non-functional., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 22/148: usrp2 impl working with data transport. not up to full potential yet, but working. needs major cleanup., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 23/148: Changed the transport to return a vector of sbuffs. This way the ethernet can pass up as many buffs as ready., git, 2016/08/14