aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/cache/thread_safe_cache.h
diff options
context:
space:
mode:
authornkmakarov <nkmakarov@yandex-team.ru>2022-02-10 16:49:06 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:06 +0300
commitf1803fa4ac9e2ee6cbfde317571ec330013392ff (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/cache/thread_safe_cache.h
parent324348a37ed08cf66897faefb0ec4bebfe7804e1 (diff)
downloadydb-f1803fa4ac9e2ee6cbfde317571ec330013392ff.tar.gz
Restoring authorship annotation for <nkmakarov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/cache/thread_safe_cache.h')
-rw-r--r--library/cpp/cache/thread_safe_cache.h46
1 files changed, 23 insertions, 23 deletions
diff --git a/library/cpp/cache/thread_safe_cache.h b/library/cpp/cache/thread_safe_cache.h
index 396ddec757..71e1442717 100644
--- a/library/cpp/cache/thread_safe_cache.h
+++ b/library/cpp/cache/thread_safe_cache.h
@@ -50,13 +50,13 @@ namespace NPrivate {
}
const TPtr Get(TArgs... args) const {
- return GetValue<true>(args...);
+ return GetValue<true>(args...);
+ }
+
+ const TPtr GetUnsafe(TArgs... args) const {
+ return GetValue<false>(args...);
}
- const TPtr GetUnsafe(TArgs... args) const {
- return GetValue<false>(args...);
- }
-
void Clear() {
TWriteGuard w(Mutex);
Cache.Clear();
@@ -107,9 +107,9 @@ namespace NPrivate {
}
private:
- template <bool AllowNullValues>
- const TPtr GetValue(TArgs... args) const {
- Key key = Callbacks.GetKey(args...);
+ template <bool AllowNullValues>
+ const TPtr GetValue(TArgs... args) const {
+ Key key = Callbacks.GetKey(args...);
switch (GettersPromotionPolicy) {
case EGettersPromotionPolicy::Promoted:
break;
@@ -120,21 +120,21 @@ namespace NPrivate {
return i.Value();
}
break;
- }
- }
- TWriteGuard w(Mutex);
- typename TInternalCache::TIterator i = Cache.Find(key);
- if (i != Cache.End()) {
- return i.Value();
- }
- TPtr value = Callbacks.CreateObject(args...);
- if (value || AllowNullValues) {
- Cache.Insert(key, value);
- }
- return value;
- }
-
- private:
+ }
+ }
+ TWriteGuard w(Mutex);
+ typename TInternalCache::TIterator i = Cache.Find(key);
+ if (i != Cache.End()) {
+ return i.Value();
+ }
+ TPtr value = Callbacks.CreateObject(args...);
+ if (value || AllowNullValues) {
+ Cache.Insert(key, value);
+ }
+ return value;
+ }
+
+ private:
using TInternalCache = TCache<Key, TPtr, List<Key, TPtr>, TNoopDelete>;
template <class TCallbacks>