MCPcopy Create free account
hub / github.com/catboost/catboost / GetValue

Method GetValue

library/cpp/cache/thread_safe_cache.h:139–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137 private:
138 template <bool AllowNullValues>
139 const TPtr GetValue(TArgs... args) const {
140 Key key = Callbacks.GetKey(args...);
141 switch (GettersPromotionPolicy) {
142 case EGettersPromotionPolicy::Promoted:
143 break;
144 case EGettersPromotionPolicy::Unpromoted: {
145 TReadGuard r(Mutex);
146 typename TInternalCache::TIterator i = Cache.FindWithoutPromote(key);
147 if (i != Cache.End()) {
148 return i.Value();
149 }
150 break;
151 }
152 }
153 TWriteGuard w(Mutex);
154 typename TInternalCache::TIterator i = Cache.Find(key);
155 if (i != Cache.End()) {
156 return i.Value();
157 }
158 TPtr value = Callbacks.CreateObject(args...);
159 if (value || AllowNullValues) {
160 Cache.Insert(key, value);
161 }
162 return value;
163 }
164
165 private:
166 using TInternalCache = TCache<Key, TPtr, List<Key, TPtr>, TNoopDelete>;

Callers

nothing calls this directly

Calls 7

FindWithoutPromoteMethod · 0.80
GetKeyMethod · 0.45
EndMethod · 0.45
ValueMethod · 0.45
FindMethod · 0.45
CreateObjectMethod · 0.45
InsertMethod · 0.45

Tested by

no test coverage detected