diff options
| -rw-r--r-- | host/examples/network_relay.cpp | 15 | 
1 files changed, 7 insertions, 8 deletions
| diff --git a/host/examples/network_relay.cpp b/host/examples/network_relay.cpp index a12c38ff8..fc1ebd91d 100644 --- a/host/examples/network_relay.cpp +++ b/host/examples/network_relay.cpp @@ -33,9 +33,6 @@ typedef boost::shared_ptr<asio::ip::udp::socket> socket_type;  static const size_t insane_mtu = 9000; -boost::mutex spawn_mutex; -boost::condition_variable thread_spawned; -  #if defined(UHD_PLATFORM_MACOS)      //limit buffer resize on macos or it will error      const size_t rx_dsp_buff_size = size_t(1e6); @@ -101,11 +98,11 @@ public:          }          std::cout << "spawning relay threads... " << _port << std::endl; -        boost::unique_lock<boost::mutex> lock(spawn_mutex); +        boost::unique_lock<boost::mutex> lock(spawn_mutex);     // lock in preparation to wait for threads to spawn          _thread_group.create_thread(boost::bind(&udp_relay_type::server_thread, this)); -        thread_spawned.wait(lock); +        wait_for_thread.wait(lock);      // wait for thread to spin up          _thread_group.create_thread(boost::bind(&udp_relay_type::client_thread, this)); -        thread_spawned.wait(lock); +        wait_for_thread.wait(lock);      // wait for thread to spin up          std::cout << "    done!" << std::endl << std::endl;      } @@ -126,7 +123,7 @@ private:      void server_thread(void){          uhd::set_thread_priority_safe();          std::cout << "    entering server_thread..." << std::endl; -        thread_spawned.notify_one(); +        wait_for_thread.notify_one();    // notify constructor that this thread has started          std::vector<char> buff(insane_mtu);          while (not boost::this_thread::interruption_requested()){              if (wait_for_recv_ready(_server_socket->native())){ @@ -152,7 +149,7 @@ private:      void client_thread(void){          uhd::set_thread_priority_safe();          std::cout << "    entering client_thread..." << std::endl; -        thread_spawned.notify_one(); +        wait_for_thread.notify_one();    // notify constructor that this thread has started          std::vector<char> buff(insane_mtu);          while (not boost::this_thread::interruption_requested()){              if (wait_for_recv_ready(_client_socket->native())){ @@ -170,6 +167,8 @@ private:      asio::ip::udp::endpoint _endpoint;      boost::mutex _endpoint_mutex;      socket_type _server_socket, _client_socket; +    boost::mutex spawn_mutex; +    boost::condition_variable wait_for_thread;  }; | 
