aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/cache
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
parent5973931d2355b2d66faf8b1b952ba3de1e7a9324 (diff)
downloadydb-39c9b256341fc68d2d9f8e561ac985709f65f164.tar.gz
Restoring authorship annotation for <emazhukin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/cache')
-rw-r--r--library/cpp/cache/cache.cpp2
-rw-r--r--library/cpp/cache/cache.h2
-rw-r--r--library/cpp/cache/thread_safe_cache.cpp2
-rw-r--r--library/cpp/cache/thread_safe_cache.h42
-rw-r--r--library/cpp/cache/ut/cache_ut.cpp56
-rw-r--r--library/cpp/cache/ut/ya.make10
-rw-r--r--library/cpp/cache/ya.make16
7 files changed, 65 insertions, 65 deletions
diff --git a/library/cpp/cache/cache.cpp b/library/cpp/cache/cache.cpp
index 05b26b0cf8..656aac3a8d 100644
--- a/library/cpp/cache/cache.cpp
+++ b/library/cpp/cache/cache.cpp
@@ -1 +1 @@
-#include "cache.h"
+#include "cache.h"
diff --git a/library/cpp/cache/cache.h b/library/cpp/cache/cache.h
index 6dc997076d..45a7b4a517 100644
--- a/library/cpp/cache/cache.h
+++ b/library/cpp/cache/cache.h
@@ -4,7 +4,7 @@
#include <util/generic/ptr.h>
#include <util/generic/intrlist.h>
#include <util/generic/hash_set.h>
-#include <util/generic/vector.h>
+#include <util/generic/vector.h>
#include <util/generic/yexception.h>
#include <utility>
diff --git a/library/cpp/cache/thread_safe_cache.cpp b/library/cpp/cache/thread_safe_cache.cpp
index de47076d6b..e4cbbc8719 100644
--- a/library/cpp/cache/thread_safe_cache.cpp
+++ b/library/cpp/cache/thread_safe_cache.cpp
@@ -1 +1 @@
-#include "thread_safe_cache.h"
+#include "thread_safe_cache.h"
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...);
diff --git a/library/cpp/cache/ut/cache_ut.cpp b/library/cpp/cache/ut/cache_ut.cpp
index 329872cfde..36c7d509d9 100644
--- a/library/cpp/cache/ut/cache_ut.cpp
+++ b/library/cpp/cache/ut/cache_ut.cpp
@@ -1,5 +1,5 @@
-#include <library/cpp/cache/cache.h>
-#include <library/cpp/cache/thread_safe_cache.h>
+#include <library/cpp/cache/cache.h>
+#include <library/cpp/cache/thread_safe_cache.h>
#include <library/cpp/testing/unittest/registar.h>
struct TStrokaWeighter {
@@ -368,11 +368,11 @@ Y_UNIT_TEST_SUITE(TThreadSafeCacheTest) {
return i;
}
TValue* CreateObject(ui32 i) const override {
- Creations++;
+ Creations++;
return new TString(VALS[i]);
}
-
- mutable i32 Creations = 0;
+
+ mutable i32 Creations = 0;
};
Y_UNIT_TEST(SimpleTest) {
@@ -381,29 +381,29 @@ Y_UNIT_TEST_SUITE(TThreadSafeCacheTest) {
UNIT_ASSERT(data == VALS[i]);
}
}
-
- Y_UNIT_TEST(InsertUpdateTest) {
- TCallbacks callbacks;
- TCache cache(callbacks, 10);
-
- cache.Insert(2, MakeAtomicShared<TString>("hj"));
- TAtomicSharedPtr<TString> item = cache.Get(2);
-
- UNIT_ASSERT(callbacks.Creations == 0);
- UNIT_ASSERT(*item == "hj");
-
- cache.Insert(2, MakeAtomicShared<TString>("hjk"));
- item = cache.Get(2);
-
- UNIT_ASSERT(callbacks.Creations == 0);
- UNIT_ASSERT(*item == "hj");
-
- cache.Update(2, MakeAtomicShared<TString>("hjk"));
- item = cache.Get(2);
-
- UNIT_ASSERT(callbacks.Creations == 0);
- UNIT_ASSERT(*item == "hjk");
- }
+
+ Y_UNIT_TEST(InsertUpdateTest) {
+ TCallbacks callbacks;
+ TCache cache(callbacks, 10);
+
+ cache.Insert(2, MakeAtomicShared<TString>("hj"));
+ TAtomicSharedPtr<TString> item = cache.Get(2);
+
+ UNIT_ASSERT(callbacks.Creations == 0);
+ UNIT_ASSERT(*item == "hj");
+
+ cache.Insert(2, MakeAtomicShared<TString>("hjk"));
+ item = cache.Get(2);
+
+ UNIT_ASSERT(callbacks.Creations == 0);
+ UNIT_ASSERT(*item == "hj");
+
+ cache.Update(2, MakeAtomicShared<TString>("hjk"));
+ item = cache.Get(2);
+
+ UNIT_ASSERT(callbacks.Creations == 0);
+ UNIT_ASSERT(*item == "hjk");
+ }
}
Y_UNIT_TEST_SUITE(TThreadSafeCacheUnsafeTest) {
diff --git a/library/cpp/cache/ut/ya.make b/library/cpp/cache/ut/ya.make
index f660872369..bb61612e0c 100644
--- a/library/cpp/cache/ut/ya.make
+++ b/library/cpp/cache/ut/ya.make
@@ -1,12 +1,12 @@
UNITTEST()
-OWNER(
- g:util
- vskipin
-)
+OWNER(
+ g:util
+ vskipin
+)
PEERDIR(
- library/cpp/cache
+ library/cpp/cache
)
SRCS(
diff --git a/library/cpp/cache/ya.make b/library/cpp/cache/ya.make
index fd73032bf8..8987af0f5c 100644
--- a/library/cpp/cache/ya.make
+++ b/library/cpp/cache/ya.make
@@ -1,16 +1,16 @@
LIBRARY()
-OWNER(
- g:util
-)
+OWNER(
+ g:util
+)
SRCS(
cache.cpp
- thread_safe_cache.cpp
+ thread_safe_cache.cpp
)
END()
-
-RECURSE_FOR_TESTS(
- ut
-)
+
+RECURSE_FOR_TESTS(
+ ut
+)