diff options
Diffstat (limited to 'usrp2/host/lib/control.cc')
-rw-r--r-- | usrp2/host/lib/control.cc | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/usrp2/host/lib/control.cc b/usrp2/host/lib/control.cc index bb71f79c2..33a95c078 100644 --- a/usrp2/host/lib/control.cc +++ b/usrp2/host/lib/control.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,14 +23,14 @@ #include <config.h> #endif -#include <gnuradio/omni_time.h> #include "control.h" #include <iostream> +#include <gruel/thread.h> namespace usrp2 { pending_reply::pending_reply(unsigned int rid, void *buffer, size_t len) - : d_rid(rid), d_buffer(buffer), d_len(len), d_mutex(), d_cond(&d_mutex), + : d_rid(rid), d_buffer(buffer), d_len(len), d_mutex(), d_cond(), d_complete(false) { } @@ -43,22 +43,23 @@ namespace usrp2 { int pending_reply::wait_for_completion(double secs) { - omni_time abs_timeout = omni_time::time(omni_time(secs)); - omni_mutex_lock l(d_mutex); - while (!d_complete){ - int r = d_cond.timedwait(abs_timeout.d_secs, abs_timeout.d_nsecs); - if (r == 0) // timed out - return 0; + gruel::scoped_lock l(d_mutex); + boost::system_time to(gruel::get_new_timeout(secs)); + + while (!d_complete) { + if (!d_cond.timed_wait(l, to)) + return 0; // timed out } + return 1; } void pending_reply::notify_completion() { - omni_mutex_lock l(d_mutex); + gruel::scoped_lock l(d_mutex); d_complete = true; - d_cond.signal(); + d_cond.notify_one(); } } // namespace usrp2 |