| 35 | } |
| 36 | |
| 37 | std::unique_ptr<ResourceType> Get(const KeyType &key) { |
| 38 | std::lock_guard<std::mutex> lg(lock_); |
| 39 | |
| 40 | auto &&it = key2resources_.find(key); |
| 41 | if (key2resources_.end() == it) return nullptr; |
| 42 | auto &resources = it->second; |
| 43 | if (resources.empty()) return nullptr; |
| 44 | auto resource = std::move(resources.front()); |
| 45 | resources.pop(); |
| 46 | return resource; |
| 47 | } |
| 48 | |
| 49 | void Put(const KeyType &key, std::unique_ptr<ResourceType> &resource) { |
| 50 | std::lock_guard<std::mutex> lg(lock_); |
nothing calls this directly
no outgoing calls
no test coverage detected