aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorAlexander Gololobov <davenger@yandex-team.com>2022-02-10 16:47:38 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:38 +0300
commitfccc62e9bfdce9be2fe7e0f23479da3a5512211a (patch)
treec0748b5dcbade83af788c0abfa89c0383d6b779c /util
parent39608cdb86363c75ce55b2b9a69841c3b71f22cf (diff)
downloadydb-fccc62e9bfdce9be2fe7e0f23479da3a5512211a.tar.gz
Restoring authorship annotation for Alexander Gololobov <davenger@yandex-team.com>. Commit 2 of 2.
Diffstat (limited to 'util')
-rw-r--r--util/draft/holder_vector.h20
-rw-r--r--util/generic/object_counter.h2
-rw-r--r--util/memory/benchmark/pool/main.cpp30
-rw-r--r--util/memory/benchmark/pool/metrics/main.py8
-rw-r--r--util/memory/benchmark/pool/metrics/ya.make20
-rw-r--r--util/memory/benchmark/pool/ya.make14
-rw-r--r--util/memory/benchmark/ya.make8
-rw-r--r--util/memory/pool.cpp18
-rw-r--r--util/memory/pool.h16
-rw-r--r--util/memory/pool_ut.cpp28
-rw-r--r--util/stream/aligned.h4
-rw-r--r--util/string/cast.cpp22
-rw-r--r--util/string/cast_ut.cpp6
-rw-r--r--util/system/align.h6
-rw-r--r--util/system/align_ut.cpp14
-rw-r--r--util/system/context.h2
-rw-r--r--util/system/dynlib.cpp4
-rw-r--r--util/system/dynlib.h12
-rw-r--r--util/system/sanitizers.h4
-rw-r--r--util/system/thread.cpp2
-rw-r--r--util/system/thread.h2
-rw-r--r--util/thread/lfstack.h6
-rw-r--r--util/thread/lfstack_ut.cpp92
23 files changed, 170 insertions, 170 deletions
diff --git a/util/draft/holder_vector.h b/util/draft/holder_vector.h
index 0cf4689f6c..1c62055bd9 100644
--- a/util/draft/holder_vector.h
+++ b/util/draft/holder_vector.h
@@ -20,8 +20,8 @@ public:
void Clear() {
for (typename TBase::iterator it = TBase::begin(); it != TBase::end(); ++it) {
- if (*it)
- D::Destroy(*it);
+ if (*it)
+ D::Destroy(*it);
}
TBase::clear();
}
@@ -33,11 +33,11 @@ public:
// TVector takes ownership of T
void PushBack(T* t) {
try {
- TBase::push_back(t);
+ TBase::push_back(t);
} catch (...) {
- if (t)
- D::Destroy(t);
- throw;
+ if (t)
+ D::Destroy(t);
+ throw;
}
}
@@ -65,11 +65,11 @@ public:
}
}
- T* Release(size_t i) {
- T* t = (*this)[i];
+ T* Release(size_t i) {
+ T* t = (*this)[i];
(*this)[i] = nullptr;
- return t;
- }
+ return t;
+ }
void Resize(size_t newSize) {
for (size_t i = newSize; i < size(); ++i) {
diff --git a/util/generic/object_counter.h b/util/generic/object_counter.h
index 893d4b810f..5257afa2e6 100644
--- a/util/generic/object_counter.h
+++ b/util/generic/object_counter.h
@@ -32,7 +32,7 @@ public:
}
static inline long ObjectCount() noexcept {
- return AtomicGet(Count_);
+ return AtomicGet(Count_);
}
/**
diff --git a/util/memory/benchmark/pool/main.cpp b/util/memory/benchmark/pool/main.cpp
index 91f781aab7..0b4d6c94af 100644
--- a/util/memory/benchmark/pool/main.cpp
+++ b/util/memory/benchmark/pool/main.cpp
@@ -1,11 +1,11 @@
#include <library/cpp/testing/benchmark/bench.h>
-
-#include <util/memory/pool.h>
-#include <util/generic/xrange.h>
-#include <util/stream/output.h>
-
+
+#include <util/memory/pool.h>
+#include <util/generic/xrange.h>
+#include <util/stream/output.h>
+
#define BENCHMARK_POOL_ALLOC(chunkSize, allocSize, allocAlign) \
- Y_CPU_BENCHMARK(MemroyPool_chunk##chunkSize##_alloc##allocSize##_align##allocAlign, p) { \
+ Y_CPU_BENCHMARK(MemroyPool_chunk##chunkSize##_alloc##allocSize##_align##allocAlign, p) { \
TMemoryPool pool(chunkSize); \
for (auto i : xrange<size_t>(0, p.Iterations())) { \
(void)i; \
@@ -15,12 +15,12 @@
Cerr << "Allocated: " << pool.MemoryAllocated() << Endl; \
Cerr << "Waste: " << pool.MemoryWaste() << Endl; \
*/ \
- }
-
-BENCHMARK_POOL_ALLOC(4096, 1, 1)
-BENCHMARK_POOL_ALLOC(4096, 2, 2)
-BENCHMARK_POOL_ALLOC(4096, 3, 4)
-BENCHMARK_POOL_ALLOC(4096, 7, 8)
-BENCHMARK_POOL_ALLOC(4096, 17, 16)
-BENCHMARK_POOL_ALLOC(4096, 40, 64)
-BENCHMARK_POOL_ALLOC(4096, 77, 128)
+ }
+
+BENCHMARK_POOL_ALLOC(4096, 1, 1)
+BENCHMARK_POOL_ALLOC(4096, 2, 2)
+BENCHMARK_POOL_ALLOC(4096, 3, 4)
+BENCHMARK_POOL_ALLOC(4096, 7, 8)
+BENCHMARK_POOL_ALLOC(4096, 17, 16)
+BENCHMARK_POOL_ALLOC(4096, 40, 64)
+BENCHMARK_POOL_ALLOC(4096, 77, 128)
diff --git a/util/memory/benchmark/pool/metrics/main.py b/util/memory/benchmark/pool/metrics/main.py
index 1738ef91dc..cc17b7b888 100644
--- a/util/memory/benchmark/pool/metrics/main.py
+++ b/util/memory/benchmark/pool/metrics/main.py
@@ -1,5 +1,5 @@
-import yatest.common as yc
-
-
-def test_export_metrics(metrics):
+import yatest.common as yc
+
+
+def test_export_metrics(metrics):
metrics.set_benchmark(yc.execute_benchmark('util/memory/benchmark/pool/pool', threads=8))
diff --git a/util/memory/benchmark/pool/metrics/ya.make b/util/memory/benchmark/pool/metrics/ya.make
index 413ab1ecb2..c671bc5c1c 100644
--- a/util/memory/benchmark/pool/metrics/ya.make
+++ b/util/memory/benchmark/pool/metrics/ya.make
@@ -1,18 +1,18 @@
OWNER(g:util)
SUBSCRIBER(g:util-subscribers)
-
+
PY2TEST()
-
+
SIZE(LARGE)
-
-TAG(
+
+TAG(
ya:force_sandbox
- sb:intel_e5_2660v1
+ sb:intel_e5_2660v1
ya:fat
-)
-
+)
+
TEST_SRCS(main.py)
-
+
DEPENDS(util/memory/benchmark/pool)
-
-END()
+
+END()
diff --git a/util/memory/benchmark/pool/ya.make b/util/memory/benchmark/pool/ya.make
index 1b48c71ae3..5f4f7d3f15 100644
--- a/util/memory/benchmark/pool/ya.make
+++ b/util/memory/benchmark/pool/ya.make
@@ -1,10 +1,10 @@
OWNER(g:util)
SUBSCRIBER(g:util-subscribers)
-
+
Y_BENCHMARK()
-
-SRCS(
- main.cpp
-)
-
-END()
+
+SRCS(
+ main.cpp
+)
+
+END()
diff --git a/util/memory/benchmark/ya.make b/util/memory/benchmark/ya.make
index 0d6de5c96e..2259b9434e 100644
--- a/util/memory/benchmark/ya.make
+++ b/util/memory/benchmark/ya.make
@@ -1,7 +1,7 @@
OWNER(g:util)
SUBSCRIBER(g:util-subscribers)
-
-RECURSE(
- pool
+
+RECURSE(
+ pool
pool/metrics
-)
+)
diff --git a/util/memory/pool.cpp b/util/memory/pool.cpp
index 138e5afc8a..9a011f0e4f 100644
--- a/util/memory/pool.cpp
+++ b/util/memory/pool.cpp
@@ -17,12 +17,12 @@ void TMemoryPool::AddChunk(size_t hint) {
}
TBlock nb = Alloc_->Allocate(allocSize);
- // Add previous chunk's stats
- if (Current_ != &Empty_) {
- MemoryAllocatedBeforeCurrent_ += Current_->Used();
- MemoryWasteBeforeCurrent_ += Current_->Left();
- }
-
+ // Add previous chunk's stats
+ if (Current_ != &Empty_) {
+ MemoryAllocatedBeforeCurrent_ += Current_->Used();
+ MemoryWasteBeforeCurrent_ += Current_->Left();
+ }
+
BlockSize_ = GrowPolicy_->Next(dataLen);
Current_ = new (nb.Data) TChunk(nb.Len - sizeof(TChunk));
Chunks_.PushBack(Current_);
@@ -38,7 +38,7 @@ void TMemoryPool::DoClear(bool keepfirst) noexcept {
Current_ = c;
BlockSize_ = c->BlockLength() - sizeof(TChunk);
MemoryAllocatedBeforeCurrent_ = 0;
- MemoryWasteBeforeCurrent_ = 0;
+ MemoryWasteBeforeCurrent_ = 0;
return;
}
@@ -50,6 +50,6 @@ void TMemoryPool::DoClear(bool keepfirst) noexcept {
Current_ = &Empty_;
BlockSize_ = Origin_;
- MemoryAllocatedBeforeCurrent_ = 0;
- MemoryWasteBeforeCurrent_ = 0;
+ MemoryAllocatedBeforeCurrent_ = 0;
+ MemoryWasteBeforeCurrent_ = 0;
}
diff --git a/util/memory/pool.h b/util/memory/pool.h
index a50403749a..13c8b6b9ed 100644
--- a/util/memory/pool.h
+++ b/util/memory/pool.h
@@ -138,8 +138,8 @@ public:
, Alloc_(alloc)
, Options_(options)
, Origin_(initial)
- , MemoryAllocatedBeforeCurrent_(0)
- , MemoryWasteBeforeCurrent_(0)
+ , MemoryAllocatedBeforeCurrent_(0)
+ , MemoryWasteBeforeCurrent_(0)
{
}
@@ -245,11 +245,11 @@ public:
}
inline size_t MemoryAllocated() const noexcept {
- return MemoryAllocatedBeforeCurrent_ + (Current_ != &Empty_ ? Current_->Used() : 0);
+ return MemoryAllocatedBeforeCurrent_ + (Current_ != &Empty_ ? Current_->Used() : 0);
}
inline size_t MemoryWaste() const noexcept {
- return MemoryWasteBeforeCurrent_ + (Current_ != &Empty_ ? Current_->Left() : 0);
+ return MemoryWasteBeforeCurrent_ + (Current_ != &Empty_ ? Current_->Left() : 0);
}
template <class TOp>
@@ -277,14 +277,14 @@ protected:
}
inline void* RawAllocate(size_t len, size_t align) {
- Y_ASSERT(align > 0);
+ Y_ASSERT(align > 0);
void* ret = Current_->Allocate(len, align);
if (ret) {
return ret;
}
- AddChunk(len + align - 1);
+ AddChunk(len + align - 1);
return Current_->Allocate(len, align);
}
@@ -302,8 +302,8 @@ private:
TOptions Options_;
TChunkList Chunks_;
const size_t Origin_;
- size_t MemoryAllocatedBeforeCurrent_;
- size_t MemoryWasteBeforeCurrent_;
+ size_t MemoryAllocatedBeforeCurrent_;
+ size_t MemoryWasteBeforeCurrent_;
};
template <typename TPool>
diff --git a/util/memory/pool_ut.cpp b/util/memory/pool_ut.cpp
index 3e963bb8ef..1158a8ca42 100644
--- a/util/memory/pool_ut.cpp
+++ b/util/memory/pool_ut.cpp
@@ -126,12 +126,12 @@ private:
UNIT_ASSERT(m);
memset(m, 0, i);
}
-
- pool.Clear();
-
- UNIT_ASSERT_VALUES_EQUAL(0, pool.MemoryAllocated());
- UNIT_ASSERT_VALUES_EQUAL(0, pool.MemoryWaste());
- UNIT_ASSERT_VALUES_EQUAL(0, pool.Available());
+
+ pool.Clear();
+
+ UNIT_ASSERT_VALUES_EQUAL(0, pool.MemoryAllocated());
+ UNIT_ASSERT_VALUES_EQUAL(0, pool.MemoryWaste());
+ UNIT_ASSERT_VALUES_EQUAL(0, pool.Available());
}
alloc.CheckAtEnd();
@@ -180,14 +180,14 @@ private:
void* aligned8 = pool.Allocate(3, 8);
void* aligned1024 = pool.Allocate(3, 1024);
- UNIT_ASSERT_VALUES_UNEQUAL(aligned16, nullptr);
- UNIT_ASSERT_VALUES_UNEQUAL(aligned2, nullptr);
- UNIT_ASSERT_VALUES_UNEQUAL(aligned128, nullptr);
- UNIT_ASSERT_VALUES_UNEQUAL(aligned4, nullptr);
- UNIT_ASSERT_VALUES_UNEQUAL(aligned256, nullptr);
- UNIT_ASSERT_VALUES_UNEQUAL(aligned8, nullptr);
- UNIT_ASSERT_VALUES_UNEQUAL(aligned1024, nullptr);
-
+ UNIT_ASSERT_VALUES_UNEQUAL(aligned16, nullptr);
+ UNIT_ASSERT_VALUES_UNEQUAL(aligned2, nullptr);
+ UNIT_ASSERT_VALUES_UNEQUAL(aligned128, nullptr);
+ UNIT_ASSERT_VALUES_UNEQUAL(aligned4, nullptr);
+ UNIT_ASSERT_VALUES_UNEQUAL(aligned256, nullptr);
+ UNIT_ASSERT_VALUES_UNEQUAL(aligned8, nullptr);
+ UNIT_ASSERT_VALUES_UNEQUAL(aligned1024, nullptr);
+
UNIT_ASSERT_VALUES_EQUAL(reinterpret_cast<uintptr_t>(aligned2) & 1, 0);
UNIT_ASSERT_VALUES_EQUAL(reinterpret_cast<uintptr_t>(aligned4) & 3, 0);
UNIT_ASSERT_VALUES_EQUAL(reinterpret_cast<uintptr_t>(aligned8) & 7, 0);
diff --git a/util/stream/aligned.h b/util/stream/aligned.h
index 92fef15ea7..70e7be05a9 100644
--- a/util/stream/aligned.h
+++ b/util/stream/aligned.h
@@ -69,8 +69,8 @@ public:
size_t GetCurrentOffset() const {
return Position_;
- }
-
+ }
+
/**
* Ensures alignment of the position in the output stream by writing
* some data.
diff --git a/util/string/cast.cpp b/util/string/cast.cpp
index 8c40983c84..aa1e65a8e9 100644
--- a/util/string/cast.cpp
+++ b/util/string/cast.cpp
@@ -640,9 +640,9 @@ DEF_FLT_SPEC(long double)
#undef DEF_FLT_SPEC
-// Using StrToD for float and double because it is faster than sscanf.
+// Using StrToD for float and double because it is faster than sscanf.
// Exception-free, specialized for float types
-template <>
+template <>
bool TryFromStringImpl<double>(const char* data, size_t len, double& result) {
if (!len) {
return false;
@@ -680,19 +680,19 @@ bool TryFromStringImpl<long double>(const char* data, size_t len, long double& r
// Exception-throwing, specialized for float types
template <>
-double FromStringImpl<double>(const char* data, size_t len) {
+double FromStringImpl<double>(const char* data, size_t len) {
double d = 0.0;
if (!TryFromStringImpl(data, len, d)) {
ythrow TFromStringException() << TStringBuf("cannot parse float(") << TStringBuf(data, len) << TStringBuf(")");
- }
- return d;
-}
-
-template <>
-float FromStringImpl<float>(const char* data, size_t len) {
+ }
+ return d;
+}
+
+template <>
+float FromStringImpl<float>(const char* data, size_t len) {
return static_cast<float>(FromStringImpl<double>(data, len));
-}
-
+}
+
double StrToD(const char* b, const char* e, char** se) {
struct TCvt: public StringToDoubleConverter {
inline TCvt()
diff --git a/util/string/cast_ut.cpp b/util/string/cast_ut.cpp
index 7f54dcde32..033450c38c 100644
--- a/util/string/cast_ut.cpp
+++ b/util/string/cast_ut.cpp
@@ -163,7 +163,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
f = FromString<TFloat>(str);
UNIT_ASSERT_DOUBLES_EQUAL(f, canonValue, eps);
}
-
+
template <class TFloat>
void BadFloatTester(const char* str) {
const double eps = 10E-5;
@@ -175,7 +175,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
UNIT_ASSERT_EXCEPTION(f = FromString<TFloat>(str), TFromStringException);
Y_UNUSED(f); // shut up compiler about 'assigned value that is not used'
}
-
+
Y_UNIT_TEST(TestToFrom) {
test1(bool, true);
test1(bool, false);
@@ -315,7 +315,7 @@ Y_UNIT_TEST_SUITE(TCastTest) {
BadFloatTester<long double>("10e 2");
BadFloatTester<long double>(""); // IGNIETFERRO-300
}
-
+
Y_UNIT_TEST(TestLiteral) {
UNIT_ASSERT_VALUES_EQUAL(ToString("abc"), TString("abc"));
}
diff --git a/util/system/align.h b/util/system/align.h
index 9d7ba39a36..ea0bbc5b46 100644
--- a/util/system/align.h
+++ b/util/system/align.h
@@ -15,9 +15,9 @@ static inline T AlignUp(T len, T align) noexcept {
const T alignedResult = AlignDown(len + (align - 1), align);
Y_ASSERT(alignedResult >= len); // check for overflow
return alignedResult;
-}
-
-template <class T>
+}
+
+template <class T>
static inline T AlignUpSpace(T len, T align) noexcept {
Y_ASSERT(IsPowerOf2(align)); // align should be power of 2
return ((T)0 - len) & (align - 1); // AlignUp(len, align) - len;
diff --git a/util/system/align_ut.cpp b/util/system/align_ut.cpp
index 6b24cbac52..3ba3a3442b 100644
--- a/util/system/align_ut.cpp
+++ b/util/system/align_ut.cpp
@@ -1,13 +1,13 @@
-#include "align.h"
-
+#include "align.h"
+
#include <library/cpp/testing/unittest/registar.h>
-class TAlignTest: public TTestBase {
+class TAlignTest: public TTestBase {
UNIT_TEST_SUITE(TAlignTest);
UNIT_TEST(TestDown)
UNIT_TEST(TestUp)
UNIT_TEST_SUITE_END();
-
+
private:
inline void TestDown() {
UNIT_ASSERT(AlignDown(0, 4) == 0);
@@ -30,6 +30,6 @@ private:
UNIT_ASSERT(AlignUp(0, 8) == 0);
UNIT_ASSERT(AlignUp(1, 8) == 8);
}
-};
-
-UNIT_TEST_SUITE_REGISTRATION(TAlignTest);
+};
+
+UNIT_TEST_SUITE_REGISTRATION(TAlignTest);
diff --git a/util/system/context.h b/util/system/context.h
index 5f6ac024c6..d2a349bfc5 100644
--- a/util/system/context.h
+++ b/util/system/context.h
@@ -2,7 +2,7 @@
#include "align.h"
#include "defaults.h"
-#include "compiler.h"
+#include "compiler.h"
#include "sanitizers.h"
#include <util/generic/array_ref.h>
diff --git a/util/system/dynlib.cpp b/util/system/dynlib.cpp
index 8363db22dc..9d2541c25f 100644
--- a/util/system/dynlib.cpp
+++ b/util/system/dynlib.cpp
@@ -105,8 +105,8 @@ TDynamicLibrary::TDynamicLibrary(const TString& path, int flags) {
TDynamicLibrary::~TDynamicLibrary() = default;
-void TDynamicLibrary::Open(const char* path, int flags) {
- Impl_.Reset(TImpl::SafeCreate(path, flags));
+void TDynamicLibrary::Open(const char* path, int flags) {
+ Impl_.Reset(TImpl::SafeCreate(path, flags));
}
void TDynamicLibrary::Close() noexcept {
diff --git a/util/system/dynlib.h b/util/system/dynlib.h
index d2e426aebb..66eaf4a5c1 100644
--- a/util/system/dynlib.h
+++ b/util/system/dynlib.h
@@ -8,18 +8,18 @@
#define Y_GET_FUNC(dll, name) FUNC_##name((dll).Sym(#name))
#define Y_GET_FUNC_OPTIONAL(dll, name) FUNC_##name((dll).SymOptional(#name))
-#ifdef _win32_
+#ifdef _win32_
#define DEFAULT_DLLOPEN_FLAGS 0
-#else
+#else
#include <dlfcn.h>
-
+
#ifndef RTLD_GLOBAL
#define RTLD_GLOBAL (0)
#endif
-
+
#define DEFAULT_DLLOPEN_FLAGS (RTLD_NOW | RTLD_GLOBAL)
-#endif
-
+#endif
+
class TDynamicLibrary {
public:
TDynamicLibrary() noexcept;
diff --git a/util/system/sanitizers.h b/util/system/sanitizers.h
index c1896ca637..965e5c751e 100644
--- a/util/system/sanitizers.h
+++ b/util/system/sanitizers.h
@@ -60,9 +60,9 @@ namespace NSan {
return true;
#else
return false;
-#endif
+#endif
}
-
+
// Determines if tsan present
inline constexpr static bool TSanIsOn() noexcept {
#if defined(_tsan_enabled_)
diff --git a/util/system/thread.cpp b/util/system/thread.cpp
index 0cd8c078ea..6236746c2d 100644
--- a/util/system/thread.cpp
+++ b/util/system/thread.cpp
@@ -358,7 +358,7 @@ TThread::TId TThread::ImpossibleThreadId() noexcept {
namespace {
template <class T>
- static void* ThreadProcWrapper(void* param) {
+ static void* ThreadProcWrapper(void* param) {
return reinterpret_cast<T*>(param)->ThreadProc();
}
}
diff --git a/util/system/thread.h b/util/system/thread.h
index 612c25f86e..a6e8abdb5b 100644
--- a/util/system/thread.h
+++ b/util/system/thread.h
@@ -163,7 +163,7 @@ public:
virtual ~ISimpleThread() = default;
- virtual void* ThreadProc() = 0;
+ virtual void* ThreadProc() = 0;
};
struct TCurrentThreadLimits {
diff --git a/util/thread/lfstack.h b/util/thread/lfstack.h
index 7a046e00b2..ca3d95f3c3 100644
--- a/util/thread/lfstack.h
+++ b/util/thread/lfstack.h
@@ -98,7 +98,7 @@ public:
bool Dequeue(T* res) {
AtomicAdd(DequeueCount, 1);
for (TNode* current = AtomicGet(Head); current; current = AtomicGet(Head)) {
- if (AtomicCas(&Head, AtomicGet(current->Next), current)) {
+ if (AtomicCas(&Head, AtomicGet(current->Next), current)) {
*res = std::move(current->Value);
// delete current; // ABA problem
// even more complex node deletion
@@ -109,7 +109,7 @@ public:
} else {
// Dequeue()s in progress, put node to free list
for (;;) {
- AtomicSet(current->Next, AtomicGet(FreePtr));
+ AtomicSet(current->Next, AtomicGet(FreePtr));
if (AtomicCas(&FreePtr, current, current->Next))
break;
}
@@ -145,7 +145,7 @@ public:
currentLast = currentLast->Next;
}
for (;;) {
- AtomicSet(currentLast->Next, AtomicGet(FreePtr));
+ AtomicSet(currentLast->Next, AtomicGet(FreePtr));
if (AtomicCas(&FreePtr, current, currentLast->Next))
break;
}
diff --git a/util/thread/lfstack_ut.cpp b/util/thread/lfstack_ut.cpp
index 38371bfc71..e20a838f95 100644
--- a/util/thread/lfstack_ut.cpp
+++ b/util/thread/lfstack_ut.cpp
@@ -1,7 +1,7 @@
#include <util/system/atomic.h>
#include <util/system/event.h>
-#include <util/generic/deque.h>
+#include <util/generic/deque.h>
#include <library/cpp/threading/future/legacy_future.h>
#include <library/cpp/testing/unittest/registar.h>
@@ -189,7 +189,7 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) {
UNIT_ASSERT_VALUES_EQUAL(1, p.RefCount());
}
-
+
Y_UNIT_TEST(NoCopyTest) {
static unsigned copied = 0;
struct TCopyCount {
@@ -232,53 +232,53 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) {
struct TMultiThreadTester {
using ThisType = TMultiThreadTester<TTest>;
- size_t Threads;
- size_t OperationsPerThread;
-
- TCountDownLatch StartLatch;
+ size_t Threads;
+ size_t OperationsPerThread;
+
+ TCountDownLatch StartLatch;
TLockFreeStack<typename TTest::ValueType> Stack;
-
+
TMultiThreadTester()
- : Threads(10)
- , OperationsPerThread(100000)
- , StartLatch(Threads)
- {
- }
-
- void Worker() {
- StartLatch.CountDown();
- StartLatch.Await();
-
+ : Threads(10)
+ , OperationsPerThread(100000)
+ , StartLatch(Threads)
+ {
+ }
+
+ void Worker() {
+ StartLatch.CountDown();
+ StartLatch.Await();
+
TVector<typename TTest::ValueType> unused;
- for (size_t i = 0; i < OperationsPerThread; ++i) {
- switch (GetCycleCount() % 4) {
- case 0: {
+ for (size_t i = 0; i < OperationsPerThread; ++i) {
+ switch (GetCycleCount() % 4) {
+ case 0: {
TTest::Enqueue(Stack, i);
- break;
- }
- case 1: {
+ break;
+ }
+ case 1: {
TTest::Dequeue(Stack);
- break;
- }
- case 2: {
+ break;
+ }
+ case 2: {
TTest::EnqueueAll(Stack);
- break;
- }
- case 3: {
+ break;
+ }
+ case 3: {
TTest::DequeueAll(Stack);
- break;
- }
- }
- }
- }
-
- void Run() {
- TDeque<NThreading::TLegacyFuture<>> futures;
-
- for (size_t i = 0; i < Threads; ++i) {
+ break;
+ }
+ }
+ }
+ }
+
+ void Run() {
+ TDeque<NThreading::TLegacyFuture<>> futures;
+
+ for (size_t i = 0; i < Threads; ++i) {
futures.emplace_back(std::bind(&ThisType::Worker, this));
- }
- futures.clear();
+ }
+ futures.clear();
TTest::DequeueAll(Stack);
}
};
@@ -288,7 +288,7 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) {
static void Enqueue(TLockFreeStack<int>& stack, size_t i) {
stack.Enqueue(static_cast<int>(i));
- }
+ }
static void Dequeue(TLockFreeStack<int>& stack) {
int value;
@@ -304,12 +304,12 @@ Y_UNIT_TEST_SUITE(TLockFreeStackTests) {
TVector<int> value;
stack.DequeueAll(&value);
}
- };
-
- // Test for catching thread sanitizer problems
+ };
+
+ // Test for catching thread sanitizer problems
Y_UNIT_TEST(TestFreeList) {
TMultiThreadTester<TFreeListTest>().Run();
- }
+ }
struct TMoveTest {
using ValueType = THolder<int>;