summaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/b100
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-07-13 17:25:40 -0700
committerJosh Blum <josh@joshknows.com>2011-07-13 17:25:40 -0700
commit7e1b2a0e3c014bc23aaa7a045efb5f1109818051 (patch)
tree748f2f0cb78d133a478f61a14b7a18a4de560673 /host/lib/usrp/b100
parent9d470d5db39c75308f3ac15a8512f08b714b4ee4 (diff)
downloaduhd-7e1b2a0e3c014bc23aaa7a045efb5f1109818051.tar.gz
uhd-7e1b2a0e3c014bc23aaa7a045efb5f1109818051.tar.bz2
uhd-7e1b2a0e3c014bc23aaa7a045efb5f1109818051.zip
uhd: added tasks to simplify thread spawning use cases
Diffstat (limited to 'host/lib/usrp/b100')
-rw-r--r--host/lib/usrp/b100/b100_ctrl.cpp20
1 files changed, 7 insertions, 13 deletions
diff --git a/host/lib/usrp/b100/b100_ctrl.cpp b/host/lib/usrp/b100/b100_ctrl.cpp
index 5b03fd591..e08b47ce4 100644
--- a/host/lib/usrp/b100/b100_ctrl.cpp
+++ b/host/lib/usrp/b100/b100_ctrl.cpp
@@ -22,10 +22,12 @@
#include <uhd/transport/vrt_if_packet.hpp>
#include <uhd/utils/thread_priority.hpp>
#include <uhd/utils/msg.hpp>
+#include <uhd/utils/tasks.hpp>
#include <uhd/types/metadata.hpp>
#include <uhd/types/serial.hpp>
#include "ctrl_packet.hpp"
-#include <boost/thread.hpp>
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
#include <uhd/exception.hpp>
using namespace uhd::transport;
@@ -40,19 +42,12 @@ public:
_ctrl_transport(ctrl_transport),
_seq(0)
{
- boost::barrier spawn_barrier(2);
- viking_marauders.create_thread(boost::bind(&b100_ctrl_impl::viking_marauder_loop, this, boost::ref(spawn_barrier)));
- spawn_barrier.wait();
+ viking_marauder = task::make(boost::bind(&b100_ctrl_impl::viking_marauder_loop, this));
}
int write(boost::uint32_t addr, const ctrl_data_t &data);
ctrl_data_t read(boost::uint32_t addr, size_t len);
- ~b100_ctrl_impl(void) {
- viking_marauders.interrupt_all();
- viking_marauders.join_all();
- }
-
bool get_ctrl_data(ctrl_data_t &pkt_data, double timeout);
void poke32(wb_addr_type addr, boost::uint32_t data){
@@ -95,10 +90,10 @@ private:
int send_pkt(boost::uint16_t *cmd);
//änd hërë wë gö ä-Vïkïng för äsynchronous control packets
- void viking_marauder_loop(boost::barrier &);
+ void viking_marauder_loop(void);
bounded_buffer<ctrl_data_t> sync_ctrl_fifo;
async_cb_type _async_cb;
- boost::thread_group viking_marauders;
+ task::sptr viking_marauder;
uhd::transport::zero_copy_if::sptr _ctrl_transport;
boost::uint8_t _seq;
@@ -206,8 +201,7 @@ ctrl_data_t b100_ctrl_impl::read(boost::uint32_t addr, size_t len) {
* never have more than 1 message in it, since it's expected that we'll
* wait for a control operation to finish before starting another one.
**********************************************************************/
-void b100_ctrl_impl::viking_marauder_loop(boost::barrier &spawn_barrier) {
- spawn_barrier.wait();
+void b100_ctrl_impl::viking_marauder_loop(void){
set_thread_priority_safe();
while (not boost::this_thread::interruption_requested()){