Skip to content

Commit 2f54daf

Browse files
committed
atomics for multithreaded consumers
1 parent 310f089 commit 2f54daf

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/Consumer.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ class Consumer
4242
// Function called just after stopping data taking, after the last call to pushData(). Not called before input FIFO empty.
4343
virtual int stop()
4444
{
45-
theLog.log(LogInfoDevel_(3003), "Push statistics for %s: %llu err / %llu total (DataSets), %llu/%llu filtered (DataBlocks)", this->name.c_str(), totalPushError, totalPushError + totalPushSuccess, totalBlocksFiltered, totalBlocksUnfiltered + totalBlocksFiltered);
45+
theLog.log(LogInfoDevel_(3003), "Push statistics for %s: %llu err / %llu total (DataSets), %llu/%llu filtered (DataBlocks)",
46+
this->name.c_str(), totalPushError.load(), totalPushError.load() + totalPushSuccess.load(), totalBlocksFiltered.load(), totalBlocksUnfiltered.load() + totalBlocksFiltered.load());
4647
return 0;
4748
};
4849

@@ -53,10 +54,10 @@ class Consumer
5354
bool stopOnError = false; // if set, readout will stop when this consumer reports an error (isError flag or pushData() failing)
5455
int isError = 0; // flag which might be used to count number of errors occuring in the consumer
5556
bool isErrorReported = false; // flag to keep track of error reports for this consumer
56-
unsigned long long totalPushSuccess = 0;
57-
unsigned long long totalPushError = 0;
58-
unsigned long long totalBlocksFiltered = 0;
59-
unsigned long long totalBlocksUnfiltered = 0;
57+
std::atomic<unsigned long long> totalPushSuccess = 0;
58+
std::atomic<unsigned long long> totalPushError = 0;
59+
std::atomic<unsigned long long> totalBlocksFiltered = 0;
60+
std::atomic<unsigned long long> totalBlocksUnfiltered = 0;
6061

6162
protected:
6263
// check if a DataBlock passes defined filters. Return 1 if ok, zero if not.

0 commit comments

Comments
 (0)