14 #include "tbb/concurrent_unordered_map.h"
36 struct ErrorSummaryMapKey {
41 bool operator<(ErrorSummaryMapKey
const& iOther)
const {
42 int comp =
severity.getLevel() - iOther.severity.getLevel();
46 comp = module.compare(iOther.module);
52 bool operator==(ErrorSummaryMapKey
const& iOther)
const {
53 return ((iOther.category ==
category) and (iOther.module == module) and
54 (
severity.getLevel() == iOther.severity.getLevel()));
56 size_t smallHash()
const {
57 std::hash<std::string>
h;
63 std::size_t operator()(ErrorSummaryMapKey
const& iKey)
const {
return iKey.smallHash(); }
67 class AtomicUnsignedInt {
69 AtomicUnsignedInt() : value_(0) {}
70 AtomicUnsignedInt(AtomicUnsignedInt
const&
r) : value_(
r.value_.load(std::memory_order_acquire)) {}
71 std::atomic<unsigned int>&
value() {
return value_; }
72 std::atomic<unsigned int>
const&
value()
const {
return value_; }
75 std::atomic<unsigned int> value_;
83 tbb::concurrent_unordered_map<ErrorSummaryMapKey, AtomicUnsignedInt, ErrorSummaryMapKey::key_hash>>
87 : errorobj_p(suppressed ? nullptr : new
ErrorObj(sev,
id, verbatim), ErrorObjDeleter()) {
94 void MessageSender::ErrorObjDeleter::operator()(
ErrorObj* errorObjPtr) {
95 if (errorObjPtr ==
nullptr) {
113 std::cerr <<
"MessageSender::~MessageSender() - Null drop pointer \n";
122 auto i = errorSummaryMap.find(
key);
123 if (
i != errorSummaryMap.end()) {
124 i->second.value().fetch_add(1, std::memory_order_acq_rel);
126 errorSummaryMap[
key].value().store(1, std::memory_order_release);
149 using namespace messagelogger;
169 std::vector<ErrorSummaryEntry>
v;
170 auto end = errorSummaryMap.end();
171 for (
auto i = errorSummaryMap.begin();
i !=
end; ++
i) {
172 auto const&
key =
i->first;
175 e.count =
i->second.value().load(std::memory_order_acquire);
190 std::vector<ErrorSummaryEntry>
v;
193 auto end = errorSummaryMap.end();
194 for (
auto i = errorSummaryMap.begin();
i !=
end; ++
i) {
195 auto const&
key =
i->first;
198 e.count =
i->second.value().load(std::memory_order_acquire);