From 2a82dc07c5ec5a0fcb6b7a2ba6f9d8686b500794 Mon Sep 17 00:00:00 2001 From: albertoesmp Date: Thu, 5 Oct 2023 18:51:27 +0200 Subject: [PATCH] Tuning yielder mutex ... --- src/main/helios_version.cpp | 2 +- src/scanner/MultiScanner.cpp | 2 +- src/scanner/MultiScanner.h | 2 +- src/scanner/Scanner.h | 3 ++- src/scanner/ScanningDevice.cpp | 2 +- src/scanner/ScanningDevice.h | 2 +- src/scanner/SingleScanner.cpp | 2 +- src/scanner/SingleScanner.h | 2 +- src/scanner/detector/FullWaveformPulseRunnable.cpp | 6 +++--- src/scanner/detector/FullWaveformPulseRunnable.h | 2 +- src/util/Yielder.h | 14 ++++++++++++-- 11 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/main/helios_version.cpp b/src/main/helios_version.cpp index bfc9db9ca..279b9ae17 100644 --- a/src/main/helios_version.cpp +++ b/src/main/helios_version.cpp @@ -4,7 +4,7 @@ const char * HELIOS_VERSION = "1.2.0"; -const char * HELIOS_GIT_HASH = "5cba90e3"; +const char * HELIOS_GIT_HASH = "3d0656db"; const char * getHeliosVersion(){ return HELIOS_VERSION; diff --git a/src/scanner/MultiScanner.cpp b/src/scanner/MultiScanner.cpp index f5ef8c018..0358075cf 100644 --- a/src/scanner/MultiScanner.cpp +++ b/src/scanner/MultiScanner.cpp @@ -160,7 +160,7 @@ Rotation MultiScanner::calcAbsoluteBeamAttitude(size_t const idx){ } void MultiScanner::computeSubrays( std::function &intersectionHandlingNoiseSource, std::map &reflections, diff --git a/src/scanner/MultiScanner.h b/src/scanner/MultiScanner.h index 609dc9d7e..23a44b03c 100644 --- a/src/scanner/MultiScanner.h +++ b/src/scanner/MultiScanner.h @@ -157,7 +157,7 @@ class MultiScanner : public Scanner{ */ void computeSubrays( std::function &intersectionHandlingNoiseSource, std::map &reflections, diff --git a/src/scanner/Scanner.h b/src/scanner/Scanner.h index 243c305fe..34597e80a 100644 --- a/src/scanner/Scanner.h +++ b/src/scanner/Scanner.h @@ -440,7 +440,8 @@ class Scanner : public Asset { */ virtual void computeSubrays( std::function &intersectionHandlingNoiseSource, std::map &reflections, diff --git a/src/scanner/ScanningDevice.cpp b/src/scanner/ScanningDevice.cpp index c9ee9fc1a..c7e703e5c 100644 --- a/src/scanner/ScanningDevice.cpp +++ b/src/scanner/ScanningDevice.cpp @@ -255,7 +255,7 @@ Rotation ScanningDevice::calcExactAbsoluteBeamAttitude( void ScanningDevice::computeSubrays( std::function &intersectionHandlingNoiseSource, std::map &reflections, diff --git a/src/scanner/ScanningDevice.h b/src/scanner/ScanningDevice.h index 165627586..f171076ad 100644 --- a/src/scanner/ScanningDevice.h +++ b/src/scanner/ScanningDevice.h @@ -317,7 +317,7 @@ class ScanningDevice : public Asset { */ void computeSubrays( std::function &intersectionHandlingNoiseSource, std::map &reflections, diff --git a/src/scanner/SingleScanner.cpp b/src/scanner/SingleScanner.cpp index d2f64f1ce..44071b44e 100644 --- a/src/scanner/SingleScanner.cpp +++ b/src/scanner/SingleScanner.cpp @@ -196,7 +196,7 @@ Rotation SingleScanner::calcAbsoluteBeamAttitude(size_t const idx) { } void SingleScanner::computeSubrays( std::function &intersectionHandlingNoiseSource, std::map &reflections, diff --git a/src/scanner/SingleScanner.h b/src/scanner/SingleScanner.h index 34343ddcc..a6d55e263 100644 --- a/src/scanner/SingleScanner.h +++ b/src/scanner/SingleScanner.h @@ -130,7 +130,7 @@ class SingleScanner : public Scanner{ */ void computeSubrays( std::function &intersectionHandlingNoiseSource, std::map &reflections, diff --git a/src/scanner/detector/FullWaveformPulseRunnable.cpp b/src/scanner/detector/FullWaveformPulseRunnable.cpp index 4709067ea..f44019c98 100644 --- a/src/scanner/detector/FullWaveformPulseRunnable.cpp +++ b/src/scanner/detector/FullWaveformPulseRunnable.cpp @@ -121,7 +121,7 @@ void FullWaveformPulseRunnable::computeSubrays( ){ scanner->computeSubrays( [&] ( - Rotation &subrayRotation, + Rotation const &subrayRotation, double const divergenceAngle, NoiseSource &intersectionHandlingNoiseSource, std::map &reflections, @@ -155,7 +155,7 @@ void FullWaveformPulseRunnable::computeSubrays( } void FullWaveformPulseRunnable::handleSubray( - Rotation &subrayRotation, + Rotation const &subrayRotation, double const divergenceAngle, NoiseSource &intersectionHandlingNoiseSource, map &reflections, @@ -239,7 +239,7 @@ void FullWaveformPulseRunnable::handleSubray( double intensity = 0.0; if (intersect->prim->canComputeSigmaWithLadLut()) { // LadLut based intensity computation - double sigma = intersect->prim->computeSigmaWithLadLut( + double const sigma = intersect->prim->computeSigmaWithLadLut( subrayDirection ); intensity = scanner->calcIntensity( diff --git a/src/scanner/detector/FullWaveformPulseRunnable.h b/src/scanner/detector/FullWaveformPulseRunnable.h index 8f9744c82..c88c4ef3b 100644 --- a/src/scanner/detector/FullWaveformPulseRunnable.h +++ b/src/scanner/detector/FullWaveformPulseRunnable.h @@ -103,7 +103,7 @@ class FullWaveformPulseRunnable : public AbstractPulseRunnable { * @see FullWaveformPulseRunnable::computeSubrays */ void handleSubray( - Rotation &subrayRotation, + Rotation const &subrayRotation, double const divergenceAngle, NoiseSource &intersectionHandlingNoiseSource, std::map &reflections, diff --git a/src/util/Yielder.h b/src/util/Yielder.h index 3c387e266..2ea0e38fb 100644 --- a/src/util/Yielder.h +++ b/src/util/Yielder.h @@ -70,8 +70,18 @@ class Yielder{ inline void push(T const &elem){ mtx.lock(); buffer.push_back(elem); - mtx.unlock(); - if(buffer.size() >= bufferSize) yield(); + if(buffer.size() >= bufferSize){ + // Copy what must be written before releasing the mutex + vector copy = copyBuffer(); + // Empty buffer before releasing the mutex + buffer.clear(); + mtx.unlock(); + // Digest temporal copy + digest(copy); + } + else{ + mtx.unlock(); + } } /**