diff options
author | emazhukin <emazhukin@yandex-team.ru> | 2022-02-10 16:48:56 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:56 +0300 |
commit | 39c9b256341fc68d2d9f8e561ac985709f65f164 (patch) | |
tree | f449899a12ddc8707a22128e28a370f8d101f69a /library/cpp/cache/thread_safe_cache.h | |
parent | 5973931d2355b2d66faf8b1b952ba3de1e7a9324 (diff) | |
download | ydb-39c9b256341fc68d2d9f8e561ac985709f65f164.tar.gz |
Restoring authorship annotation for <emazhukin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/cache/thread_safe_cache.h')
-rw-r--r-- | library/cpp/cache/thread_safe_cache.h | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/library/cpp/cache/thread_safe_cache.h b/library/cpp/cache/thread_safe_cache.h index 71e1442717..8c12fe2dae 100644 --- a/library/cpp/cache/thread_safe_cache.h +++ b/library/cpp/cache/thread_safe_cache.h @@ -36,19 +36,19 @@ namespace NPrivate { { } - bool Insert(const Key& key, const TPtr& value) { - if (!Contains(key)) { - TWriteGuard w(Mutex); - return Cache.Insert(key, value); - } - return false; - } - - void Update(const Key& key, const TPtr& value) { - TWriteGuard w(Mutex); - Cache.Update(key, value); - } - + bool Insert(const Key& key, const TPtr& value) { + if (!Contains(key)) { + TWriteGuard w(Mutex); + return Cache.Insert(key, value); + } + return false; + } + + void Update(const Key& key, const TPtr& value) { + TWriteGuard w(Mutex); + Cache.Update(key, value); + } + const TPtr Get(TArgs... args) const { return GetValue<true>(args...); } @@ -64,8 +64,8 @@ namespace NPrivate { void Erase(TArgs... args) { Key key = Callbacks.GetKey(args...); - if (!Contains(key)) { - return; + if (!Contains(key)) { + return; } TWriteGuard w(Mutex); typename TInternalCache::TIterator i = Cache.Find(key); @@ -75,12 +75,12 @@ namespace NPrivate { Cache.Erase(i); } - bool Contains(const Key& key) const { - TReadGuard r(Mutex); - auto iter = Cache.FindWithoutPromote(key); - return iter != Cache.End(); - } - + bool Contains(const Key& key) const { + TReadGuard r(Mutex); + auto iter = Cache.FindWithoutPromote(key); + return iter != Cache.End(); + } + template <class TCallbacks> static const TPtr Get(TArgs... args) { return TThreadSafeCacheSingleton<TCallbacks>::Get(args...); |