From 11a452545c97d3c65d9935ad3a96a9ab63f39d0d Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Tue, 2 Apr 2019 15:44:19 +0200 Subject: [PATCH] added parallel call for void return --- .../include/multiSlsDetector.h | 8 ++++++ slsDetectorSoftware/src/multiSlsDetector.cpp | 27 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/slsDetectorSoftware/include/multiSlsDetector.h b/slsDetectorSoftware/include/multiSlsDetector.h index 13e2ae1e2..084450ede 100644 --- a/slsDetectorSoftware/include/multiSlsDetector.h +++ b/slsDetectorSoftware/include/multiSlsDetector.h @@ -168,6 +168,14 @@ class multiSlsDetector : public virtual slsDetectorDefs { std::vector parallelCall(RT (slsDetector::*somefunc)(CT...) const, typename NonDeduced::type... Args) const; + + template + void parallelCall(void (slsDetector::*somefunc)(CT...), typename NonDeduced::type... Args); + + template + void parallelCall(void (slsDetector::*somefunc)(CT...) const, typename NonDeduced::type... Args) const; + + /** * Decodes which detector and the corresponding channel numbers for it * Mainly useful in a multi detector setROI (Gotthard, Mythen?) diff --git a/slsDetectorSoftware/src/multiSlsDetector.cpp b/slsDetectorSoftware/src/multiSlsDetector.cpp index 11bc0c456..5a3d29bae 100644 --- a/slsDetectorSoftware/src/multiSlsDetector.cpp +++ b/slsDetectorSoftware/src/multiSlsDetector.cpp @@ -98,6 +98,33 @@ std::vector multiSlsDetector::parallelCall(RT (slsDetector::*somefunc)(CT... return result; } +template +void multiSlsDetector::parallelCall(void (slsDetector::*somefunc)(CT...), + typename NonDeduced::type... Args) { + std::vector> futures; + for (auto &d : detectors) { + futures.push_back(std::async(std::launch::async, somefunc, d.get(), Args...)); + } + for (auto &i : futures) { + i.get(); + } + return; +} + +template +void multiSlsDetector::parallelCall(void (slsDetector::*somefunc)(CT...) const, + typename NonDeduced::type... Args) const{ + std::vector> futures; + for (auto &d : detectors) { + futures.push_back(std::async(std::launch::async, somefunc, d.get(), Args...)); + } + for (auto &i : futures) { + i.get(); + } + return; +} + + int multiSlsDetector::decodeNChannel(int offsetX, int offsetY, int &channelX, int &channelY) { channelX = -1; channelY = -1;