diff options
author | sievlev <sievlev@yandex-team.ru> | 2022-02-10 16:51:45 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:51:45 +0300 |
commit | c38d513b2c4ace7c22019ef4cc24003204b77391 (patch) | |
tree | 2d6749d50b5f7a18a7f6d8fba895a4fb633d60a5 | |
parent | 2441b91fbbba534805430952c0770c88c3df8236 (diff) | |
download | ydb-c38d513b2c4ace7c22019ef4cc24003204b77391.tar.gz |
Restoring authorship annotation for <sievlev@yandex-team.ru>. Commit 1 of 2.
-rw-r--r-- | util/generic/hash.h | 2 | ||||
-rw-r--r-- | util/generic/hash_ut.cpp | 12 | ||||
-rw-r--r-- | util/system/atomic_gcc.h | 36 | ||||
-rw-r--r-- | util/system/atomic_ops.h | 10 | ||||
-rw-r--r-- | util/system/atomic_ut.cpp | 48 | ||||
-rw-r--r-- | util/system/atomic_win.h | 8 | ||||
-rw-r--r-- | util/thread/pool.cpp | 18 |
7 files changed, 67 insertions, 67 deletions
diff --git a/util/generic/hash.h b/util/generic/hash.h index e46db21fa9..eabf69268a 100644 --- a/util/generic/hash.h +++ b/util/generic/hash.h @@ -1929,7 +1929,7 @@ public: return rep.find(key); } - template <class TheKey> + template <class TheKey> iterator find(const TheKey& key, insert_ctx& ins) { return rep.find_i(key, ins); } diff --git a/util/generic/hash_ut.cpp b/util/generic/hash_ut.cpp index 0551d58770..2e50e0a319 100644 --- a/util/generic/hash_ut.cpp +++ b/util/generic/hash_ut.cpp @@ -19,7 +19,7 @@ class THashTest: public TTestBase { UNIT_TEST(TestHMMapEqualityOperator); UNIT_TEST(TestHMMapConstructorsAndAssignments); UNIT_TEST(TestHMMap1); - UNIT_TEST(TestHMMapHas); + UNIT_TEST(TestHMMapHas); UNIT_TEST(TestHSetConstructorsAndAssignments); UNIT_TEST(TestHSetSize); UNIT_TEST(TestHSet2); @@ -70,7 +70,7 @@ protected: void TestHMMapEqualityOperator(); void TestHMMapConstructorsAndAssignments(); void TestHMMap1(); - void TestHMMapHas(); + void TestHMMapHas(); void TestHSetConstructorsAndAssignments(); void TestHSetSize(); void TestHSet2(); @@ -355,17 +355,17 @@ void THashTest::TestHMMap1() { UNIT_ASSERT(hmap.bucket_count() < 30); } -void THashTest::TestHMMapHas() { +void THashTest::TestHMMapHas() { using mmap = THashMultiMap<char, int, THash<char>, TEqualTo<char>>; - mmap m; + mmap m; m.insert(std::pair<const char, int>('X', 10)); m.insert(std::pair<const char, int>('X', 20)); m.insert(std::pair<const char, int>('Y', 32)); UNIT_ASSERT(m.contains('X')); UNIT_ASSERT(m.contains('Y')); UNIT_ASSERT(!m.contains('Z')); -} - +} + void THashTest::TestHSetConstructorsAndAssignments() { using container = THashSet<int>; diff --git a/util/system/atomic_gcc.h b/util/system/atomic_gcc.h index ed8dc2bdc5..78c713ed30 100644 --- a/util/system/atomic_gcc.h +++ b/util/system/atomic_gcc.h @@ -7,20 +7,20 @@ static inline TAtomicBase AtomicGet(const TAtomic& a) { TAtomicBase tmp; -#if defined(_arm64_) +#if defined(_arm64_) __asm__ __volatile__( "ldar %x[value], %[ptr] \n\t" : [value] "=r"(tmp) : [ptr] "Q"(a) : "memory"); -#else +#else __atomic_load(&a, &tmp, __ATOMIC_ACQUIRE); -#endif +#endif return tmp; } static inline void AtomicSet(TAtomic& a, TAtomicBase v) { -#if defined(_arm64_) +#if defined(_arm64_) __asm__ __volatile__( "stlr %x[value], %[ptr] \n\t" : [ptr] "=Q"(a) @@ -29,10 +29,10 @@ static inline void AtomicSet(TAtomic& a, TAtomicBase v) { #else __atomic_store(&a, &v, __ATOMIC_RELEASE); #endif -} +} static inline intptr_t AtomicIncrement(TAtomic& p) { - return __atomic_add_fetch(&p, 1, __ATOMIC_SEQ_CST); + return __atomic_add_fetch(&p, 1, __ATOMIC_SEQ_CST); } static inline intptr_t AtomicGetAndIncrement(TAtomic& p) { @@ -56,15 +56,15 @@ static inline intptr_t AtomicGetAndAdd(TAtomic& p, intptr_t v) { } static inline intptr_t AtomicSwap(TAtomic* p, intptr_t v) { - (void)p; // disable strange 'parameter set but not used' warning on gcc - intptr_t ret; - __atomic_exchange(p, &v, &ret, __ATOMIC_SEQ_CST); - return ret; + (void)p; // disable strange 'parameter set but not used' warning on gcc + intptr_t ret; + __atomic_exchange(p, &v, &ret, __ATOMIC_SEQ_CST); + return ret; } static inline bool AtomicCas(TAtomic* a, intptr_t exchange, intptr_t compare) { - (void)a; // disable strange 'parameter set but not used' warning on gcc - return __atomic_compare_exchange(a, &compare, &exchange, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); + (void)a; // disable strange 'parameter set but not used' warning on gcc + return __atomic_compare_exchange(a, &compare, &exchange, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); } static inline intptr_t AtomicGetAndCas(TAtomic* a, intptr_t exchange, intptr_t compare) { @@ -74,15 +74,15 @@ static inline intptr_t AtomicGetAndCas(TAtomic* a, intptr_t exchange, intptr_t c } static inline intptr_t AtomicOr(TAtomic& a, intptr_t b) { - return __atomic_or_fetch(&a, b, __ATOMIC_SEQ_CST); -} - -static inline intptr_t AtomicXor(TAtomic& a, intptr_t b) { - return __atomic_xor_fetch(&a, b, __ATOMIC_SEQ_CST); + return __atomic_or_fetch(&a, b, __ATOMIC_SEQ_CST); } +static inline intptr_t AtomicXor(TAtomic& a, intptr_t b) { + return __atomic_xor_fetch(&a, b, __ATOMIC_SEQ_CST); +} + static inline intptr_t AtomicAnd(TAtomic& a, intptr_t b) { - return __atomic_and_fetch(&a, b, __ATOMIC_SEQ_CST); + return __atomic_and_fetch(&a, b, __ATOMIC_SEQ_CST); } static inline void AtomicBarrier() { diff --git a/util/system/atomic_ops.h b/util/system/atomic_ops.h index 76766b4a0a..07bc6a6c58 100644 --- a/util/system/atomic_ops.h +++ b/util/system/atomic_ops.h @@ -114,11 +114,11 @@ inline TEnableIfCastable<T, T> AtomicAnd(T volatile& target, TAtomicBase value) return static_cast<T>(AtomicAnd(*AsAtomicPtr(&target), value)); } -template <typename T> -inline TEnableIfCastable<T, T> AtomicXor(T volatile& target, TAtomicBase value) { - return static_cast<T>(AtomicXor(*AsAtomicPtr(&target), value)); -} - +template <typename T> +inline TEnableIfCastable<T, T> AtomicXor(T volatile& target, TAtomicBase value) { + return static_cast<T>(AtomicXor(*AsAtomicPtr(&target), value)); +} + // pointer types template <typename T> diff --git a/util/system/atomic_ut.cpp b/util/system/atomic_ut.cpp index 07211ffba7..3bf68177d9 100644 --- a/util/system/atomic_ut.cpp +++ b/util/system/atomic_ut.cpp @@ -18,9 +18,9 @@ class TAtomicTest UNIT_TEST(TestAtomicSub) UNIT_TEST(TestAtomicGetAndSub) UNIT_TEST(TestAtomicSwap) - UNIT_TEST(TestAtomicOr) - UNIT_TEST(TestAtomicAnd) - UNIT_TEST(TestAtomicXor) + UNIT_TEST(TestAtomicOr) + UNIT_TEST(TestAtomicAnd) + UNIT_TEST(TestAtomicXor) UNIT_TEST(TestCAS) UNIT_TEST(TestGetAndCAS) UNIT_TEST(TestLockUnlock) @@ -152,27 +152,27 @@ private: UNIT_ASSERT_VALUES_EQUAL(v, Max<intptr_t>()); } - inline void TestAtomicOr() { - TAtomic v = 0xf0; - - UNIT_ASSERT_VALUES_EQUAL(AtomicOr(v, 0x0f), 0xff); - UNIT_ASSERT_VALUES_EQUAL(v, 0xff); - } - - inline void TestAtomicAnd() { - TAtomic v = 0xff; - - UNIT_ASSERT_VALUES_EQUAL(AtomicAnd(v, 0xf0), 0xf0); - UNIT_ASSERT_VALUES_EQUAL(v, 0xf0); - } - - inline void TestAtomicXor() { - TAtomic v = 0x00; - - UNIT_ASSERT_VALUES_EQUAL(AtomicXor(v, 0xff), 0xff); - UNIT_ASSERT_VALUES_EQUAL(AtomicXor(v, 0xff), 0x00); - } - + inline void TestAtomicOr() { + TAtomic v = 0xf0; + + UNIT_ASSERT_VALUES_EQUAL(AtomicOr(v, 0x0f), 0xff); + UNIT_ASSERT_VALUES_EQUAL(v, 0xff); + } + + inline void TestAtomicAnd() { + TAtomic v = 0xff; + + UNIT_ASSERT_VALUES_EQUAL(AtomicAnd(v, 0xf0), 0xf0); + UNIT_ASSERT_VALUES_EQUAL(v, 0xf0); + } + + inline void TestAtomicXor() { + TAtomic v = 0x00; + + UNIT_ASSERT_VALUES_EQUAL(AtomicXor(v, 0xff), 0xff); + UNIT_ASSERT_VALUES_EQUAL(AtomicXor(v, 0xff), 0x00); + } + inline void TestAtomicPtr() { int* p; AtomicSet(p, nullptr); diff --git a/util/system/atomic_win.h b/util/system/atomic_win.h index 65c290e6cc..ff36961ceb 100644 --- a/util/system/atomic_win.h +++ b/util/system/atomic_win.h @@ -100,10 +100,10 @@ static inline intptr_t AtomicAnd(TAtomic& a, intptr_t b) { return _InterlockedAnd64(&a, b) & b; } -static inline intptr_t AtomicXor(TAtomic& a, intptr_t b) { - return _InterlockedXor64(&a, b) ^ b; -} - +static inline intptr_t AtomicXor(TAtomic& a, intptr_t b) { + return _InterlockedXor64(&a, b) ^ b; +} + #endif // _x86_ //TODO diff --git a/util/thread/pool.cpp b/util/thread/pool.cpp index 05fad02e9b..cfe20d4929 100644 --- a/util/thread/pool.cpp +++ b/util/thread/pool.cpp @@ -76,7 +76,7 @@ public: , Blocking(params.Blocking_) , Catching(params.Catching_) , Namer(params) - , ShouldTerminate(1) + , ShouldTerminate(1) , MaxQueueSize(0) , ThreadCountExpected(0) , ThreadCountReal(0) @@ -98,7 +98,7 @@ public: } inline bool Add(IObjectInQueue* obj) { - if (AtomicGet(ShouldTerminate)) { + if (AtomicGet(ShouldTerminate)) { return false; } @@ -110,14 +110,14 @@ public: } with_lock (QueueMutex) { - while (MaxQueueSize > 0 && Queue.Size() >= MaxQueueSize && !AtomicGet(ShouldTerminate)) { + while (MaxQueueSize > 0 && Queue.Size() >= MaxQueueSize && !AtomicGet(ShouldTerminate)) { if (!Blocking) { return false; } QueuePopCond.Wait(QueueMutex); } - if (AtomicGet(ShouldTerminate)) { + if (AtomicGet(ShouldTerminate)) { return false; } @@ -157,7 +157,7 @@ public: private: inline void Start(size_t num, size_t maxque) { - AtomicSet(ShouldTerminate, 0); + AtomicSet(ShouldTerminate, 0); MaxQueueSize = maxque; ThreadCountExpected = num; @@ -174,7 +174,7 @@ private: } inline void Stop() { - AtomicSet(ShouldTerminate, 1); + AtomicSet(ShouldTerminate, 1); with_lock (QueueMutex) { QueuePopCond.BroadCast(); @@ -212,11 +212,11 @@ private: IObjectInQueue* job = nullptr; with_lock (QueueMutex) { - while (Queue.Empty() && !AtomicGet(ShouldTerminate)) { + while (Queue.Empty() && !AtomicGet(ShouldTerminate)) { QueuePushCond.Wait(QueueMutex); } - if (AtomicGet(ShouldTerminate) && Queue.Empty()) { + if (AtomicGet(ShouldTerminate) && Queue.Empty()) { tsr.Destroy(); break; @@ -264,7 +264,7 @@ private: TCondVar StopCond; TJobQueue Queue; TVector<TThreadRef> Tharr; - TAtomic ShouldTerminate; + TAtomic ShouldTerminate; size_t MaxQueueSize; size_t ThreadCountExpected; size_t ThreadCountReal; |