concurrencyc/include/sum.h

25 lines
307 B
C
Raw Normal View History

2024-07-05 16:14:16 +00:00
//
// Created by Christopher Hamer on 19/06/2024.
//
#include <mutex>
#ifndef TASK1_SUM_H
#define TASK1_SUM_H
// Thread-safe sum accumulator
class SumAccumulator {
public:
void add(int value);
long long getTotal();
private:
long long sum = 0;
std::mutex mtx;
};
#endif //TASK1_SUM_H