summaryrefslogtreecommitdiff
path: root/gnuradio-runtime/lib/scheduler_tpb.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-runtime/lib/scheduler_tpb.cc')
-rw-r--r--gnuradio-runtime/lib/scheduler_tpb.cc20
1 files changed, 12 insertions, 8 deletions
diff --git a/gnuradio-runtime/lib/scheduler_tpb.cc b/gnuradio-runtime/lib/scheduler_tpb.cc
index 0319a43a88..fe593670f8 100644
--- a/gnuradio-runtime/lib/scheduler_tpb.cc
+++ b/gnuradio-runtime/lib/scheduler_tpb.cc
@@ -26,6 +26,7 @@
#include "scheduler_tpb.h"
#include "tpb_thread_body.h"
#include <gnuradio/thread/thread_body_wrapper.h>
+#include <boost/make_shared.hpp>
#include <sstream>
namespace gr {
@@ -34,14 +35,15 @@ namespace gr {
{
block_sptr d_block;
int d_max_noutput_items;
+ thread::barrier_sptr d_start_sync;
public:
- tpb_container(block_sptr block, int max_noutput_items)
- : d_block(block), d_max_noutput_items(max_noutput_items) {}
+ tpb_container(block_sptr block, int max_noutput_items, thread::barrier_sptr start_sync)
+ : d_block(block), d_max_noutput_items(max_noutput_items), d_start_sync(start_sync) {}
void operator()()
{
- tpb_thread_body body(d_block, d_max_noutput_items);
+ tpb_thread_body body(d_block, d_start_sync, d_max_noutput_items);
}
};
@@ -71,6 +73,9 @@ namespace gr {
blocks[i]->detail()->set_done(false);
}
+ thread::barrier_sptr start_sync =
+ boost::make_shared<thread::barrier>(blocks.size()+1);
+
// Fire off a thead for each block
for(size_t i = 0; i < blocks.size(); i++) {
@@ -84,12 +89,11 @@ namespace gr {
else {
block_max_noutput_items = max_noutput_items;
}
-
- d_threads.create_thread(
- gr::thread::thread_body_wrapper<tpb_container>
- (tpb_container(blocks[i], block_max_noutput_items),
- name.str()));
+ d_threads.create_thread(thread::thread_body_wrapper<tpb_container>(
+ tpb_container(blocks[i], block_max_noutput_items, start_sync),
+ name.str()));
}
+ start_sync->wait();
}
scheduler_tpb::~scheduler_tpb()