MCPcopy Create free account
hub / github.com/Tencent/phxqueue / Get

Method Get

phxqueue/comm/resourcepool.h:37–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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_);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected