MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / acquire

Method acquire

Source/Falcor/Utils/SharedCache.h:54–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52struct SharedCache
53{
54 std::shared_ptr<T> acquire(Key key, const std::function<std::shared_ptr<T>()>& init)
55 {
56 std::lock_guard<std::mutex> lock(mutex);
57 auto it = cache.find(key);
58 if (it != cache.end())
59 {
60 if (auto data = it->second.lock())
61 return data;
62 else
63 cache.erase(it);
64 }
65
66 std::shared_ptr<T> data = init();
67 cache.emplace(key, data);
68 return data;
69 }
70
71 std::mutex mutex;
72 std::map<Key, std::weak_ptr<T>> cache;

Callers 4

NDSDFGridMethod · 0.80
SDFSBSMethod · 0.80
SDFSVOMethod · 0.80
FullScreenPassMethod · 0.80

Calls 4

initFunction · 0.85
lockMethod · 0.80
eraseMethod · 0.80
endMethod · 0.45

Tested by

no test coverage detected