From 1e9ff6fb0e946c8984f48fcf2ef868fb86dec5ea Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 26 Jul 2011 11:15:04 -0700 Subject: uhd: make spawn barrier a member of a task (see notes) On OSX w/ boost 1.47, this general area of code was inconsistently barfing w/ lock error. Perhaps its a boost bug, in any case, using it this way seems to solve the problem. --- host/lib/utils/tasks.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'host/lib/utils') diff --git a/host/lib/utils/tasks.cpp b/host/lib/utils/tasks.cpp index 993b484ea..1f735de06 100644 --- a/host/lib/utils/tasks.cpp +++ b/host/lib/utils/tasks.cpp @@ -27,10 +27,11 @@ using namespace uhd; class task_impl : public task{ public: - task_impl(const task_fcn_type &task_fcn){ - boost::barrier spawn_barrier(2); - _thread_group.create_thread(boost::bind(&task_impl::task_loop, this, task_fcn, boost::ref(spawn_barrier))); - spawn_barrier.wait(); + task_impl(const task_fcn_type &task_fcn): + _spawn_barrier(2) + { + _thread_group.create_thread(boost::bind(&task_impl::task_loop, this, task_fcn)); + _spawn_barrier.wait(); } ~task_impl(void){ @@ -41,9 +42,9 @@ public: private: - void task_loop(const task_fcn_type &task_fcn, boost::barrier &spawn_barrier){ + void task_loop(const task_fcn_type &task_fcn){ _running = true; - spawn_barrier.wait(); + _spawn_barrier.wait(); try{ while (_running){ @@ -72,6 +73,7 @@ private: } boost::thread_group _thread_group; + boost::barrier _spawn_barrier; bool _running; }; -- cgit v1.2.3