aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/event_ut.cpp
diff options
context:
space:
mode:
authorkimkim <kimkim@yandex-team.ru>2022-02-10 16:49:28 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:28 +0300
commit10807864acf73d00f425a23b442aac2cf34403a8 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /util/system/event_ut.cpp
parent13f84424ed9975f6827d9786087c6fe6ea265cda (diff)
downloadydb-10807864acf73d00f425a23b442aac2cf34403a8.tar.gz
Restoring authorship annotation for <kimkim@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/system/event_ut.cpp')
-rw-r--r--util/system/event_ut.cpp42
1 files changed, 21 insertions, 21 deletions
diff --git a/util/system/event_ut.cpp b/util/system/event_ut.cpp
index 685336e927..2506cb7a91 100644
--- a/util/system/event_ut.cpp
+++ b/util/system/event_ut.cpp
@@ -2,22 +2,22 @@
#include "atomic.h"
#include <library/cpp/testing/unittest/registar.h>
-
+
#include <util/thread/pool.h>
-
+
namespace {
- struct TSharedData {
- TSharedData()
- : Counter(0)
- , failed(false)
- {
- }
-
+ struct TSharedData {
+ TSharedData()
+ : Counter(0)
+ , failed(false)
+ {
+ }
+
TAtomic Counter;
TManualEvent event;
- bool failed;
- };
-
+ bool failed;
+ };
+
struct TThreadTask: public IObjectInQueue {
public:
TThreadTask(TSharedData& data, size_t id)
@@ -25,7 +25,7 @@ namespace {
, Id_(id)
{
}
-
+
void Process(void*) override {
THolder<TThreadTask> This(this);
@@ -38,16 +38,16 @@ namespace {
Data_.event.Signal();
} else {
while (!Data_.event.WaitT(TDuration::Seconds(100))) {
- }
+ }
AtomicAdd(Data_.Counter, Id_);
- }
+ }
}
-
+
private:
TSharedData& Data_;
size_t Id_;
- };
-
+ };
+
class TSignalTask: public IObjectInQueue {
private:
TManualEvent& Ev_;
@@ -89,12 +89,12 @@ Y_UNIT_TEST_SUITE(EventTest) {
queue.Start(5);
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
const size_t limit = 200;
@@ -121,7 +121,7 @@ Y_UNIT_TEST_SUITE(EventTest) {
tasks.emplace_back(MakeHolder<TSignalTask>(*owner->Ev));
tasks.emplace_back(std::move(owner));
}
-
+
TThreadPool queue;
queue.Start(4);
for (auto& task : tasks) {