aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/event_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/event_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/event_ut.cpp')
-rw-r--r--util/system/event_ut.cpp60
1 files changed, 30 insertions, 30 deletions
diff --git a/util/system/event_ut.cpp b/util/system/event_ut.cpp
index 2506cb7a91..4c2bfe4eb2 100644
--- a/util/system/event_ut.cpp
+++ b/util/system/event_ut.cpp
@@ -1,6 +1,6 @@
-#include "event.h"
-#include "atomic.h"
-
+#include "event.h"
+#include "atomic.h"
+
#include <library/cpp/testing/unittest/registar.h>
#include <util/thread/pool.h>
@@ -13,42 +13,42 @@ namespace {
{
}
- TAtomic Counter;
+ TAtomic Counter;
TManualEvent event;
bool failed;
};
- struct TThreadTask: public IObjectInQueue {
- public:
- TThreadTask(TSharedData& data, size_t id)
- : Data_(data)
- , Id_(id)
- {
- }
+ struct TThreadTask: public IObjectInQueue {
+ public:
+ TThreadTask(TSharedData& data, size_t id)
+ : Data_(data)
+ , Id_(id)
+ {
+ }
void Process(void*) override {
- THolder<TThreadTask> This(this);
-
- if (Id_ == 0) {
- usleep(100);
+ THolder<TThreadTask> This(this);
+
+ if (Id_ == 0) {
+ usleep(100);
bool cond = Data_.Counter == 0;
if (!cond) {
Data_.failed = true;
}
- Data_.event.Signal();
- } else {
- while (!Data_.event.WaitT(TDuration::Seconds(100))) {
+ Data_.event.Signal();
+ } else {
+ while (!Data_.event.WaitT(TDuration::Seconds(100))) {
}
- AtomicAdd(Data_.Counter, Id_);
+ AtomicAdd(Data_.Counter, Id_);
}
- }
+ }
- private:
- TSharedData& Data_;
- size_t Id_;
+ private:
+ TSharedData& Data_;
+ size_t Id_;
};
- class TSignalTask: public IObjectInQueue {
+ class TSignalTask: public IObjectInQueue {
private:
TManualEvent& Ev_;
@@ -63,7 +63,7 @@ namespace {
}
};
- class TOwnerTask: public IObjectInQueue {
+ class TOwnerTask: public IObjectInQueue {
public:
TManualEvent Barrier;
THolder<TManualEvent> Ev;
@@ -80,20 +80,20 @@ namespace {
}
};
-}
+}
Y_UNIT_TEST_SUITE(EventTest) {
Y_UNIT_TEST(WaitAndSignalTest) {
TSharedData data;
TThreadPool queue;
queue.Start(5);
- for (size_t i = 0; i < 5; ++i) {
+ for (size_t i = 0; i < 5; ++i) {
UNIT_ASSERT(queue.Add(new TThreadTask(data, i)));
}
queue.Stop();
UNIT_ASSERT(data.Counter == 10);
UNIT_ASSERT(!data.failed);
- }
+ }
Y_UNIT_TEST(ConcurrentSignalAndWaitTest) {
// test for problem detected by thread-sanitizer (signal/wait race) SEARCH-2113
@@ -114,7 +114,7 @@ Y_UNIT_TEST_SUITE(EventTest) {
/** Test for a problem: http://nga.at.yandex-team.ru/5772 */
Y_UNIT_TEST(DestructorBeforeSignalFinishTest) {
- return;
+ return;
TVector<THolder<IObjectInQueue>> tasks;
for (size_t i = 0; i < 1000; ++i) {
auto owner = MakeHolder<TOwnerTask>();
@@ -123,7 +123,7 @@ Y_UNIT_TEST_SUITE(EventTest) {
}
TThreadPool queue;
- queue.Start(4);
+ queue.Start(4);
for (auto& task : tasks) {
UNIT_ASSERT(queue.Add(task.Get()));
}