aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/tls_ut.cpp
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/system/tls_ut.cpp
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/system/tls_ut.cpp')
-rw-r--r--util/system/tls_ut.cpp106
1 files changed, 53 insertions, 53 deletions
diff --git a/util/system/tls_ut.cpp b/util/system/tls_ut.cpp
index e84d34b42a..3003fa1635 100644
--- a/util/system/tls_ut.cpp
+++ b/util/system/tls_ut.cpp
@@ -1,58 +1,58 @@
-#include "tls.h"
-#include "thread.h"
-
+#include "tls.h"
+#include "thread.h"
+
#include <library/cpp/testing/unittest/registar.h>
-
+
Y_UNIT_TEST_SUITE(TTestTLS) {
- struct X {
- inline X()
- : V(0)
- {
- }
-
- inline void Do() {
- ++TlsRef(V);
- }
-
- inline int Get() {
- return TlsRef(V);
- }
-
- Y_THREAD(int)
- V;
- };
-
+ struct X {
+ inline X()
+ : V(0)
+ {
+ }
+
+ inline void Do() {
+ ++TlsRef(V);
+ }
+
+ inline int Get() {
+ return TlsRef(V);
+ }
+
+ Y_THREAD(int)
+ V;
+ };
+
Y_UNIT_TEST(TestHugeSetup) {
- TArrayHolder<X> x(new X[100000]);
-
+ TArrayHolder<X> x(new X[100000]);
+
struct TThr: public ISimpleThread {
- inline TThr(X* ptr)
- : P(ptr)
- {
- }
-
+ inline TThr(X* ptr)
+ : P(ptr)
+ {
+ }
+
void* ThreadProc() noexcept override {
- for (size_t i = 0; i < 100000; ++i) {
- P[i].Do();
- }
-
- return nullptr;
- }
-
- X* P;
- };
-
- TThr thr1(x.Get());
- TThr thr2(x.Get());
-
- thr1.Start();
- thr2.Start();
-
- thr1.Join();
- thr2.Join();
-
- for (size_t i = 0; i < 100000; ++i) {
- UNIT_ASSERT_VALUES_EQUAL(x.Get()[i].Get(), 0);
- }
- }
-}
+ for (size_t i = 0; i < 100000; ++i) {
+ P[i].Do();
+ }
+
+ return nullptr;
+ }
+
+ X* P;
+ };
+
+ TThr thr1(x.Get());
+ TThr thr2(x.Get());
+
+ thr1.Start();
+ thr2.Start();
+
+ thr1.Join();
+ thr2.Join();
+
+ for (size_t i = 0; i < 100000; ++i) {
+ UNIT_ASSERT_VALUES_EQUAL(x.Get()[i].Get(), 0);
+ }
+ }
+}