From 5753bc307149f31979dc588f848801c71b331815 Mon Sep 17 00:00:00 2001 From: Trung Tran Date: Sun, 17 Jun 2018 16:37:20 -0700 Subject: liberio_zero_copy: add tx and rx mutexes --- host/lib/transport/liberio_zero_copy.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'host/lib/transport') diff --git a/host/lib/transport/liberio_zero_copy.cpp b/host/lib/transport/liberio_zero_copy.cpp index 8914cccdb..0999d78cf 100644 --- a/host/lib/transport/liberio_zero_copy.cpp +++ b/host/lib/transport/liberio_zero_copy.cpp @@ -12,6 +12,7 @@ #include #include #include +#include namespace uhd { namespace transport { @@ -204,6 +205,7 @@ public: managed_recv_buffer::sptr get_recv_buff(double timeout = 0.1) { + std::lock_guard lock(_rx_mutex); if (_next_recv_buff_index == _num_recv_bufs) _next_recv_buff_index = 0; return _mrb_pool[_next_recv_buff_index]->get_new( @@ -221,7 +223,8 @@ public: } managed_send_buffer::sptr get_send_buff(double timeout = 0.1) - { + { + std::lock_guard lock(_tx_mutex); if (_next_send_buff_index == _num_send_bufs) _next_send_buff_index = 0; return _msb_pool[_next_send_buff_index]->get_new( @@ -250,6 +253,8 @@ private: size_t _next_recv_buff_index; std::vector > _msb_pool; size_t _next_send_buff_index; + std::mutex _rx_mutex; + std::mutex _tx_mutex; }; liberio_zero_copy::sptr liberio_zero_copy::make( -- cgit v1.2.3