Add stop capability to UDPRecvModule

This commit is contained in:
2020-04-15 13:38:09 +02:00
parent d013bf6da3
commit 9b4323f803
2 changed files with 23 additions and 1 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ class UdpRecvModule {
public:
UdpRecvModule(RingBuffer<UdpFrameMetadata>& ring_buffer);
virtual ~UdpRecvModule() = default;
virtual ~UdpRecvModule();
void start_recv(
const uint16_t udp_port,
+22
View File
@@ -12,6 +12,11 @@ UdpRecvModule::UdpRecvModule(RingBuffer<UdpFrameMetadata>& ring_buffer) :
}
UdpRecvModule::~UdpRecvModule()
{
stop_recv();
}
void UdpRecvModule::start_recv(
const uint16_t udp_port,
const size_t udp_buffer_n_bytes)
@@ -49,6 +54,23 @@ void UdpRecvModule::start_recv(
udp_buffer_n_bytes);
}
void UdpRecvModule::stop_recv()
{
#ifdef DEBUG_OUTPUT
using namespace date;
using namespace chrono;
cout << "[" << system_clock::now() << "]";
cout << "UdpRecvModule::stop_recv";
cout << " Stop receiving." << endl;
#endif
is_receiving_ = false;
if (receiving_thread_.joinable()) {
receiving_thread_.join();
}
}
void UdpRecvModule::receive_thread(
const uint16_t udp_port,
const size_t udp_buffer_n_bytes)