summaryrefslogtreecommitdiffstats
path: root/library/cpp/cache/thread_safe_cache.h
diff options
context:
space:
mode:
authornkmakarov <[email protected]>2022-02-10 16:49:06 +0300
committerDaniil Cherednik <[email protected]>2022-02-10 16:49:06 +0300
commit324348a37ed08cf66897faefb0ec4bebfe7804e1 (patch)
tree8736a3afd6953763bf57544746bf1b8b5404dec6 /library/cpp/cache/thread_safe_cache.h
parent5eddcf9f19515e4be1e49ba1482d920e007a07d1 (diff)
Restoring authorship annotation for <[email protected]>. Commit 1 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 71e14427173..396ddec757d 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...);
- }
-
- const TPtr GetUnsafe(TArgs... args) const {
- return GetValue<false>(args...);
+ return GetValue<true>(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>