MCPcopy Create free account
hub / github.com/apache/thrift / setCounter

Method setCounter

contrib/fb303/cpp/FacebookBase.cpp:74–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74int64_t FacebookBase::setCounter(const std::string& key, int64_t value) {
75 counters_.lock();
76
77 // if we didn't find the key, we need to write lock the whole map to create it
78 ReadWriteCounterMap::iterator it = counters_.find(key);
79 if (it == counters_.end()) {
80 counters_[key].value = value;
81 counters_.unlock();
82 return value;
83 }
84
85 it->second.lock();
86 it->second.value = value;
87 it->second.unlock();
88 counters_.unlock();
89 return value;
90}
91
92void FacebookBase::getCounters(std::map<std::string, int64_t>& _return) {
93 // we need to lock the whole thing and actually build the map since we don't

Callers 1

reportCheckpointMethod · 0.45

Calls 4

findMethod · 0.80
lockMethod · 0.45
endMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected