载入中...
搜索中...
未找到
CapabilityOwned.cpp
浏览该文件的文档.
2
3namespace eve::cap::detail {
4namespace {
5
6struct OwnedTables {
7 std::mutex mutex;
8 std::unordered_map<std::string, std::unordered_map<std::string, OwnedSlot>> byCapability;
9 std::unordered_map<std::string, std::unordered_map<std::string, std::uint64_t>> generations;
10};
11
12OwnedTables& tables() {
13 static OwnedTables state;
14 return state;
15}
16
17} // namespace
18
19std::mutex& ownedMutex() { return tables().mutex; }
20
21std::unordered_map<std::string, OwnedSlot>& ownedSlots(const char* capabilityName) {
22 return tables().byCapability[capabilityName ? capabilityName : ""];
23}
24
25std::unordered_map<std::string, std::uint64_t>& ownedGenerations(const char* capabilityName) {
26 return tables().generations[capabilityName ? capabilityName : ""];
27}
28
30 std::scoped_lock lock(tables().mutex);
31 tables().byCapability.clear();
32 tables().generations.clear();
33}
34
35} // namespace eve::cap::detail
std::mutex mutex
std::unordered_map< std::string, std::unordered_map< std::string, std::uint64_t > > generations
std::unordered_map< std::string, std::unordered_map< std::string, OwnedSlot > > byCapability
Optional owning capability registration (shared_ptr + generation + lease).
std::unordered_map< std::string, OwnedSlot > & ownedSlots(const char *capabilityName)
std::mutex & ownedMutex()
std::unordered_map< std::string, std::uint64_t > & ownedGenerations(const char *capabilityName)