Static functions to query the stats collectors:
| 49 | |
| 50 | // Static functions to query the stats collectors: |
| 51 | size_t Statistics::GetHandle(std::string const& tag) { |
| 52 | std::lock_guard<std::mutex> lock(Instance().mutex_); |
| 53 | // Search for an existing tag. |
| 54 | map_t::iterator i = Instance().tag_map_.find(tag); |
| 55 | if (i == Instance().tag_map_.end()) { |
| 56 | // If it is not there, create a tag. |
| 57 | size_t handle = Instance().stats_collectors_.size(); |
| 58 | Instance().tag_map_[tag] = handle; |
| 59 | Instance().stats_collectors_.push_back(StatisticsMapValue()); |
| 60 | // Track the maximum tag length to help printing a table of values later. |
| 61 | Instance().max_tag_length_ = std::max(Instance().max_tag_length_, tag.size()); |
| 62 | return handle; |
| 63 | } else { |
| 64 | return i->second; |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | // Return true if a handle has been initialized for a specific tag. |
| 69 | // In contrast to GetHandle(), this allows testing for existence without |
nothing calls this directly
no test coverage detected