summaryrefslogtreecommitdiffstats
path: root/src/dabOutput/dabOutputTcp.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-02-22 17:15:12 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-02-22 17:15:12 +0100
commitef16c548dce02ef5335766d1729faf2d3c9b6ed5 (patch)
tree25ea6912d65429fbfb106dc1587ad9a4a706c78a /src/dabOutput/dabOutputTcp.cpp
parentde472d4b7f674cd24c4dafa30ca42bd73665e4f8 (diff)
downloaddabmux-ef16c548dce02ef5335766d1729faf2d3c9b6ed5.tar.gz
dabmux-ef16c548dce02ef5335766d1729faf2d3c9b6ed5.tar.bz2
dabmux-ef16c548dce02ef5335766d1729faf2d3c9b6ed5.zip
Replace boost::thread by std::thread in TCP Output
Diffstat (limited to 'src/dabOutput/dabOutputTcp.cpp')
-rw-r--r--src/dabOutput/dabOutputTcp.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/dabOutput/dabOutputTcp.cpp b/src/dabOutput/dabOutputTcp.cpp
index f5aebe0..57dc706 100644
--- a/src/dabOutput/dabOutputTcp.cpp
+++ b/src/dabOutput/dabOutputTcp.cpp
@@ -2,7 +2,7 @@
Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Her Majesty the Queen in
Right of Canada (Communications Research Center Canada)
- Copyright (C) 2016
+ Copyright (C) 2018
Matthias P. Braendli, matthias.braendli@mpb.li
http://www.opendigitalradio.org
@@ -35,7 +35,7 @@
#include <list>
#include <vector>
#include <atomic>
-#include <boost/thread.hpp>
+#include <thread>
#include "ThreadsafeQueue.h"
#include "TcpSocket.h"
@@ -60,12 +60,13 @@ class TCPConnection
auto addr = m_sock.getRemoteAddress();
etiLog.level(debug) << "New TCP Connection from " <<
addr.getHostAddress() << ":" << addr.getPort();
- m_sender_thread = boost::thread(&TCPConnection::process, this, 0);
+ m_sender_thread = std::thread(&TCPConnection::process, this, 0);
}
~TCPConnection() {
m_running = false;
- m_sender_thread.interrupt();
+ vec_u8 termination_marker;
+ queue.push(termination_marker);
m_sender_thread.join();
}
@@ -80,7 +81,7 @@ class TCPConnection
TCPConnection& operator=(const TCPConnection& other) = delete;
atomic<bool> m_running;
- boost::thread m_sender_thread;
+ std::thread m_sender_thread;
TcpSocket m_sock;
void process(long) {
@@ -88,6 +89,11 @@ class TCPConnection
vec_u8 data;
queue.wait_and_pop(data);
+ if (data.empty()) {
+ // empty vector is the termination marker
+ break;
+ }
+
try {
ssize_t sent = 0;
do {
@@ -127,7 +133,7 @@ class TCPDataDispatcher
m_listener_socket = move(sock);
m_running = true;
- m_listener_thread = boost::thread(&TCPDataDispatcher::process, this, 0);
+ m_listener_thread = std::thread(&TCPDataDispatcher::process, this, 0);
}
void Write(const vec_u8& data) {
@@ -160,7 +166,7 @@ class TCPDataDispatcher
}
atomic<bool> m_running;
- boost::thread m_listener_thread;
+ std::thread m_listener_thread;
TcpSocket m_listener_socket;
std::list<TCPConnection> m_connections;
};