From 3350e3997e2bcd4e5c1d943b940edd286bcb03ab Mon Sep 17 00:00:00 2001 From: Dhanya Thattil Date: Fri, 4 Feb 2022 08:19:46 +0100 Subject: [PATCH] fixes fromreview --- slsReceiverSoftware/src/Arping.h | 4 ++-- slsReceiverSoftware/src/Implementation.cpp | 20 +++++++------------- slsReceiverSoftware/src/Implementation.h | 4 ++-- slsReceiverSoftware/src/ThreadObject.h | 2 +- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/slsReceiverSoftware/src/Arping.h b/slsReceiverSoftware/src/Arping.h index af25815f9..3c84a398b 100644 --- a/slsReceiverSoftware/src/Arping.h +++ b/slsReceiverSoftware/src/Arping.h @@ -12,7 +12,7 @@ is listening to. #include #include -class Arping : private virtual slsDetectorDefs { +class Arping { public: void SetInterfacesAndIps(const int index, const std::string &interface, @@ -31,5 +31,5 @@ class Arping : private virtual slsDetectorDefs { std::vector(MAX_NUMBER_OF_LISTENING_THREADS); std::atomic runningFlag{false}; std::thread t; - pid_t threadId{0}; + std::atomic threadId{0}; }; diff --git a/slsReceiverSoftware/src/Implementation.cpp b/slsReceiverSoftware/src/Implementation.cpp index 1336eed2e..6a7b7d896 100644 --- a/slsReceiverSoftware/src/Implementation.cpp +++ b/slsReceiverSoftware/src/Implementation.cpp @@ -1,7 +1,6 @@ // SPDX-License-Identifier: LGPL-3.0-or-other // Copyright (C) 2021 Contributors to the SLS Detector Package #include "Implementation.h" -#include "Arping.h" #include "DataProcessor.h" #include "DataStreamer.h" #include "Fifo.h" @@ -109,9 +108,6 @@ void Implementation::SetupFifoStructure() { void Implementation::setDetectorType(const detectorType d) { - // object to create thread for arping - arping = sls::make_unique(); - detType = d; switch (detType) { case GOTTHARD: @@ -325,21 +321,19 @@ std::array Implementation::getThreadIds() const { retval[id++] = 0; } } - retval[NUM_RX_THREAD_IDS - 1] = arping->GetThreadId(); + retval[NUM_RX_THREAD_IDS - 1] = arping.GetThreadId(); return retval; } -bool Implementation::getArping() const { return arping->IsRunning(); } +bool Implementation::getArping() const { return arping.IsRunning(); } -pid_t Implementation::getArpingThreadId() const { - return arping->GetThreadId(); -} +pid_t Implementation::getArpingThreadId() const { return arping.GetThreadId(); } void Implementation::setArping(const bool i, const std::vector ips) { - if (i != arping->IsRunning()) { + if (i != arping.IsRunning()) { if (!i) { - arping->StopThread(); + arping.StopThread(); } else { // setup interface for (int i = 0; i != numUDPInterfaces; ++i) { @@ -347,9 +341,9 @@ void Implementation::setArping(const bool i, if (i == 1 && (numUDPInterfaces == 1 || detType == EIGER)) { break; } - arping->SetInterfacesAndIps(i, eth[i], ips[i]); + arping.SetInterfacesAndIps(i, eth[i], ips[i]); } - arping->StartThread(); + arping.StartThread(); } } } diff --git a/slsReceiverSoftware/src/Implementation.h b/slsReceiverSoftware/src/Implementation.h index 0caf3dc72..442f1b4db 100644 --- a/slsReceiverSoftware/src/Implementation.h +++ b/slsReceiverSoftware/src/Implementation.h @@ -1,6 +1,7 @@ // SPDX-License-Identifier: LGPL-3.0-or-other // Copyright (C) 2021 Contributors to the SLS Detector Package #pragma once +#include "Arping.h" #include "receiver_defs.h" #include "sls/container_utils.h" #include "sls/logger.h" @@ -11,7 +12,6 @@ class DataProcessor; class DataStreamer; class Fifo; class slsDetectorDefs; -class Arping; #include #include @@ -383,7 +383,7 @@ class Implementation : private virtual slsDetectorDefs { std::vector> dataProcessor; std::vector> dataStreamer; std::vector> fifo; - std::unique_ptr arping; + Arping arping; std::mutex hdf5Lib; }; diff --git a/slsReceiverSoftware/src/ThreadObject.h b/slsReceiverSoftware/src/ThreadObject.h index 8b42538a8..c708b960b 100644 --- a/slsReceiverSoftware/src/ThreadObject.h +++ b/slsReceiverSoftware/src/ThreadObject.h @@ -45,5 +45,5 @@ class ThreadObject : private virtual slsDetectorDefs { std::thread threadObject; sem_t semaphore; const std::string type; - pid_t threadId{0}; + std::atomic threadId{0}; };