fixes fromreview

This commit is contained in:
maliakal_d 2022-02-04 08:19:46 +01:00
parent 26faaa307b
commit 3350e3997e
4 changed files with 12 additions and 18 deletions

View File

@ -12,7 +12,7 @@ is listening to.
#include <atomic> #include <atomic>
#include <thread> #include <thread>
class Arping : private virtual slsDetectorDefs { class Arping {
public: public:
void SetInterfacesAndIps(const int index, const std::string &interface, void SetInterfacesAndIps(const int index, const std::string &interface,
@ -31,5 +31,5 @@ class Arping : private virtual slsDetectorDefs {
std::vector<std::string>(MAX_NUMBER_OF_LISTENING_THREADS); std::vector<std::string>(MAX_NUMBER_OF_LISTENING_THREADS);
std::atomic<bool> runningFlag{false}; std::atomic<bool> runningFlag{false};
std::thread t; std::thread t;
pid_t threadId{0}; std::atomic<pid_t> threadId{0};
}; };

View File

@ -1,7 +1,6 @@
// SPDX-License-Identifier: LGPL-3.0-or-other // SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package // Copyright (C) 2021 Contributors to the SLS Detector Package
#include "Implementation.h" #include "Implementation.h"
#include "Arping.h"
#include "DataProcessor.h" #include "DataProcessor.h"
#include "DataStreamer.h" #include "DataStreamer.h"
#include "Fifo.h" #include "Fifo.h"
@ -109,9 +108,6 @@ void Implementation::SetupFifoStructure() {
void Implementation::setDetectorType(const detectorType d) { void Implementation::setDetectorType(const detectorType d) {
// object to create thread for arping
arping = sls::make_unique<Arping>();
detType = d; detType = d;
switch (detType) { switch (detType) {
case GOTTHARD: case GOTTHARD:
@ -325,21 +321,19 @@ std::array<pid_t, NUM_RX_THREAD_IDS> Implementation::getThreadIds() const {
retval[id++] = 0; retval[id++] = 0;
} }
} }
retval[NUM_RX_THREAD_IDS - 1] = arping->GetThreadId(); retval[NUM_RX_THREAD_IDS - 1] = arping.GetThreadId();
return retval; return retval;
} }
bool Implementation::getArping() const { return arping->IsRunning(); } bool Implementation::getArping() const { return arping.IsRunning(); }
pid_t Implementation::getArpingThreadId() const { pid_t Implementation::getArpingThreadId() const { return arping.GetThreadId(); }
return arping->GetThreadId();
}
void Implementation::setArping(const bool i, void Implementation::setArping(const bool i,
const std::vector<std::string> ips) { const std::vector<std::string> ips) {
if (i != arping->IsRunning()) { if (i != arping.IsRunning()) {
if (!i) { if (!i) {
arping->StopThread(); arping.StopThread();
} else { } else {
// setup interface // setup interface
for (int i = 0; i != numUDPInterfaces; ++i) { for (int i = 0; i != numUDPInterfaces; ++i) {
@ -347,9 +341,9 @@ void Implementation::setArping(const bool i,
if (i == 1 && (numUDPInterfaces == 1 || detType == EIGER)) { if (i == 1 && (numUDPInterfaces == 1 || detType == EIGER)) {
break; break;
} }
arping->SetInterfacesAndIps(i, eth[i], ips[i]); arping.SetInterfacesAndIps(i, eth[i], ips[i]);
} }
arping->StartThread(); arping.StartThread();
} }
} }
} }

View File

@ -1,6 +1,7 @@
// SPDX-License-Identifier: LGPL-3.0-or-other // SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package // Copyright (C) 2021 Contributors to the SLS Detector Package
#pragma once #pragma once
#include "Arping.h"
#include "receiver_defs.h" #include "receiver_defs.h"
#include "sls/container_utils.h" #include "sls/container_utils.h"
#include "sls/logger.h" #include "sls/logger.h"
@ -11,7 +12,6 @@ class DataProcessor;
class DataStreamer; class DataStreamer;
class Fifo; class Fifo;
class slsDetectorDefs; class slsDetectorDefs;
class Arping;
#include <atomic> #include <atomic>
#include <chrono> #include <chrono>
@ -383,7 +383,7 @@ class Implementation : private virtual slsDetectorDefs {
std::vector<std::unique_ptr<DataProcessor>> dataProcessor; std::vector<std::unique_ptr<DataProcessor>> dataProcessor;
std::vector<std::unique_ptr<DataStreamer>> dataStreamer; std::vector<std::unique_ptr<DataStreamer>> dataStreamer;
std::vector<std::unique_ptr<Fifo>> fifo; std::vector<std::unique_ptr<Fifo>> fifo;
std::unique_ptr<Arping> arping; Arping arping;
std::mutex hdf5Lib; std::mutex hdf5Lib;
}; };

View File

@ -45,5 +45,5 @@ class ThreadObject : private virtual slsDetectorDefs {
std::thread threadObject; std::thread threadObject;
sem_t semaphore; sem_t semaphore;
const std::string type; const std::string type;
pid_t threadId{0}; std::atomic<pid_t> threadId{0};
}; };