aboutsummaryrefslogtreecommitdiffstats
path: root/src/output/Feedback.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-04-10 22:23:50 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-04-10 22:23:50 +0200
commitc5ddbfe33759dd80447c45513a05a4755797b05a (patch)
tree22229a36d5bf531099d30960e15501bd7e374b63 /src/output/Feedback.cpp
parentc125ae1f00fe8d8dbafce2f262ebaa8af515ac39 (diff)
downloaddabmod-c5ddbfe33759dd80447c45513a05a4755797b05a.tar.gz
dabmod-c5ddbfe33759dd80447c45513a05a4755797b05a.tar.bz2
dabmod-c5ddbfe33759dd80447c45513a05a4755797b05a.zip
Replace boost in output/Feedback
Diffstat (limited to 'src/output/Feedback.cpp')
-rw-r--r--src/output/Feedback.cpp28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/output/Feedback.cpp b/src/output/Feedback.cpp
index 97d6e04..f9c1af1 100644
--- a/src/output/Feedback.cpp
+++ b/src/output/Feedback.cpp
@@ -40,7 +40,6 @@ DESCRIPTION:
#include <sys/socket.h>
#include <errno.h>
#include <poll.h>
-#include <boost/date_time/posix_time/posix_time.hpp>
#include "output/Feedback.h"
#include "Utils.h"
#include "Socket.h"
@@ -60,10 +59,10 @@ DPDFeedbackServer::DPDFeedbackServer(
if (m_port) {
m_running.store(true);
- rx_burst_thread = boost::thread(
+ rx_burst_thread = std::thread(
&DPDFeedbackServer::ReceiveBurstThread, this);
- burst_tcp_thread = boost::thread(
+ burst_tcp_thread = std::thread(
&DPDFeedbackServer::ServeFeedbackThread, this);
}
}
@@ -72,12 +71,12 @@ DPDFeedbackServer::~DPDFeedbackServer()
{
m_running.store(false);
- rx_burst_thread.interrupt();
+ burstRequest.mutex_notification.notify_all();
+
if (rx_burst_thread.joinable()) {
rx_burst_thread.join();
}
- burst_tcp_thread.interrupt();
if (burst_tcp_thread.joinable()) {
burst_tcp_thread.join();
}
@@ -91,7 +90,7 @@ void DPDFeedbackServer::set_tx_frame(
throw runtime_error("DPDFeedbackServer not running");
}
- boost::mutex::scoped_lock lock(burstRequest.mutex);
+ unique_lock<mutex> lock(burstRequest.mutex);
if (buf.size() % sizeof(complexf) != 0) {
throw logic_error("Buffer for tx frame has incorrect size");
@@ -137,7 +136,7 @@ void DPDFeedbackServer::ReceiveBurstThread()
set_thread_name("dpdreceiveburst");
while (m_running) {
- boost::mutex::scoped_lock lock(burstRequest.mutex);
+ unique_lock<mutex> lock(burstRequest.mutex);
while (burstRequest.state != BurstRequestState::SaveReceiveFrame) {
if (not m_running) break;
burstRequest.mutex_notification.wait(lock);
@@ -192,9 +191,6 @@ void DPDFeedbackServer::ReceiveBurstThread()
catch (const std::exception &e) {
etiLog.level(error) << "DPD Feedback RX exception: " << e.what();
}
- catch (const boost::thread_interrupted& e) {
- etiLog.level(info) << "DPD Feedback RX stopping.";
- }
catch (...) {
etiLog.level(error) << "DPD Feedback RX unknown exception!";
}
@@ -213,6 +209,10 @@ void DPDFeedbackServer::ServeFeedback()
struct sockaddr_in client;
TCPSocket client_sock = m_server_sock.accept_with_timeout(1000, &client);
+ if (not m_running) {
+ break;
+ }
+
if (not client_sock.valid()) {
// No connection request received
continue;
@@ -243,15 +243,13 @@ void DPDFeedbackServer::ServeFeedback()
// We are ready to issue the request now
{
- boost::mutex::scoped_lock lock(burstRequest.mutex);
+ unique_lock<mutex> lock(burstRequest.mutex);
burstRequest.num_samples = num_samples;
burstRequest.state = BurstRequestState::SaveTransmitFrame;
-
- lock.unlock();
}
// Wait for the result to be ready
- boost::mutex::scoped_lock lock(burstRequest.mutex);
+ unique_lock<mutex> lock(burstRequest.mutex);
while (burstRequest.state != BurstRequestState::Acquired) {
if (not m_running) break;
burstRequest.mutex_notification.wait(lock);
@@ -350,7 +348,7 @@ void DPDFeedbackServer::ServeFeedbackThread()
etiLog.level(error) << "DPD Feedback Server unknown exception!";
}
- boost::this_thread::sleep(boost::posix_time::seconds(5));
+ this_thread::sleep_for(chrono::seconds(5));
}
m_running.store(false);