aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/cache/thread_safe_cache.h
diff options
context:
space:
mode:
authoremazhukin <emazhukin@yandex-team.ru>2022-02-10 16:48:56 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:56 +0300
commit39c9b256341fc68d2d9f8e561ac985709f65f164 (patch)
treef449899a12ddc8707a22128e28a370f8d101f69a /library/cpp/cache/thread_safe_cache.h
parent5973931d2355b2d66faf8b1b952ba3de1e7a9324 (diff)
downloadydb-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.h42
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...);