| 72 | } |
| 73 | |
| 74 | int64_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 | |
| 92 | void 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 |
no test coverage detected