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:57 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:57 +0300
commitb53be0c12e1650189ff223aa1f3a646222a86057 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/cache/thread_safe_cache.h
parent39c9b256341fc68d2d9f8e561ac985709f65f164 (diff)
downloadydb-b53be0c12e1650189ff223aa1f3a646222a86057.tar.gz
Restoring authorship annotation for <emazhukin@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.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 8c12fe2dae..71e1442717 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...);