aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/threading
diff options
context:
space:
mode:
authorvmordovin <vmordovin@yandex-team.ru>2022-02-10 16:48:14 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:14 +0300
commit7c7f9bbcf57e15838d15afa94b31d8254b5d7776 (patch)
tree17073f853e6b3a1a95708e8aa0ea12fa42a717e7 /library/cpp/threading
parent466f96709329ff77ded50177df94d1893a226c00 (diff)
downloadydb-7c7f9bbcf57e15838d15afa94b31d8254b5d7776.tar.gz
Restoring authorship annotation for <vmordovin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/threading')
-rw-r--r--library/cpp/threading/atomic/bool.cpp2
-rw-r--r--library/cpp/threading/atomic/bool.h54
-rw-r--r--library/cpp/threading/atomic/bool_ut.cpp56
-rw-r--r--library/cpp/threading/atomic/ut/ya.make16
-rw-r--r--library/cpp/threading/atomic/ya.make18
-rw-r--r--library/cpp/threading/task_scheduler/task_scheduler_ut.cpp106
6 files changed, 126 insertions, 126 deletions
diff --git a/library/cpp/threading/atomic/bool.cpp b/library/cpp/threading/atomic/bool.cpp
index 37917e01f1..9dd6d2cc7e 100644
--- a/library/cpp/threading/atomic/bool.cpp
+++ b/library/cpp/threading/atomic/bool.cpp
@@ -1 +1 @@
-#include "bool.h"
+#include "bool.h"
diff --git a/library/cpp/threading/atomic/bool.h b/library/cpp/threading/atomic/bool.h
index d52544e762..13b5e5356a 100644
--- a/library/cpp/threading/atomic/bool.h
+++ b/library/cpp/threading/atomic/bool.h
@@ -1,36 +1,36 @@
#pragma once
-#include <util/system/atomic.h>
-
-namespace NAtomic {
- class TBool {
- public:
- TBool() noexcept = default;
-
- TBool(bool val) noexcept
- : Val_(val)
- {
- }
-
+#include <util/system/atomic.h>
+
+namespace NAtomic {
+ class TBool {
+ public:
+ TBool() noexcept = default;
+
+ TBool(bool val) noexcept
+ : Val_(val)
+ {
+ }
+
TBool(const TBool& src) noexcept {
AtomicSet(Val_, AtomicGet(src.Val_));
}
- operator bool() const noexcept {
- return AtomicGet(Val_);
- }
-
+ operator bool() const noexcept {
+ return AtomicGet(Val_);
+ }
+
const TBool& operator=(bool val) noexcept {
- AtomicSet(Val_, val);
- return *this;
- }
-
+ AtomicSet(Val_, val);
+ return *this;
+ }
+
const TBool& operator=(const TBool& src) noexcept {
- AtomicSet(Val_, AtomicGet(src.Val_));
- return *this;
- }
-
- private:
- TAtomic Val_ = 0;
- };
+ AtomicSet(Val_, AtomicGet(src.Val_));
+ return *this;
+ }
+
+ private:
+ TAtomic Val_ = 0;
+ };
}
diff --git a/library/cpp/threading/atomic/bool_ut.cpp b/library/cpp/threading/atomic/bool_ut.cpp
index 9481f41d8d..4f417e090f 100644
--- a/library/cpp/threading/atomic/bool_ut.cpp
+++ b/library/cpp/threading/atomic/bool_ut.cpp
@@ -1,31 +1,31 @@
-#include "bool.h"
-
+#include "bool.h"
+
#include <library/cpp/testing/unittest/registar.h>
-
+
Y_UNIT_TEST_SUITE(AtomicBool) {
Y_UNIT_TEST(ReadWrite) {
- NAtomic::TBool v;
-
- UNIT_ASSERT_VALUES_EQUAL((bool)v, false);
-
- v = true;
-
- UNIT_ASSERT_VALUES_EQUAL((bool)v, true);
-
- v = false;
-
- UNIT_ASSERT_VALUES_EQUAL((bool)v, false);
-
- NAtomic::TBool v2;
-
- UNIT_ASSERT(v == v2);
-
- v2 = true;
-
- UNIT_ASSERT(v != v2);
-
- v = v2;
-
- UNIT_ASSERT(v == v2);
- }
-}
+ NAtomic::TBool v;
+
+ UNIT_ASSERT_VALUES_EQUAL((bool)v, false);
+
+ v = true;
+
+ UNIT_ASSERT_VALUES_EQUAL((bool)v, true);
+
+ v = false;
+
+ UNIT_ASSERT_VALUES_EQUAL((bool)v, false);
+
+ NAtomic::TBool v2;
+
+ UNIT_ASSERT(v == v2);
+
+ v2 = true;
+
+ UNIT_ASSERT(v != v2);
+
+ v = v2;
+
+ UNIT_ASSERT(v == v2);
+ }
+}
diff --git a/library/cpp/threading/atomic/ut/ya.make b/library/cpp/threading/atomic/ut/ya.make
index 3c555685df..2cdf002704 100644
--- a/library/cpp/threading/atomic/ut/ya.make
+++ b/library/cpp/threading/atomic/ut/ya.make
@@ -1,9 +1,9 @@
UNITTEST_FOR(library/cpp/threading/atomic)
-
-OWNER(vmordovin)
-
-SRCS(
- bool_ut.cpp
-)
-
-END()
+
+OWNER(vmordovin)
+
+SRCS(
+ bool_ut.cpp
+)
+
+END()
diff --git a/library/cpp/threading/atomic/ya.make b/library/cpp/threading/atomic/ya.make
index c3a3ef8a76..6d7989bff0 100644
--- a/library/cpp/threading/atomic/ya.make
+++ b/library/cpp/threading/atomic/ya.make
@@ -1,9 +1,9 @@
-LIBRARY()
-
-OWNER(vmordovin)
-
-SRCS(
- bool.cpp
-)
-
-END()
+LIBRARY()
+
+OWNER(vmordovin)
+
+SRCS(
+ bool.cpp
+)
+
+END()
diff --git a/library/cpp/threading/task_scheduler/task_scheduler_ut.cpp b/library/cpp/threading/task_scheduler/task_scheduler_ut.cpp
index 3b5203194a..d94e4bfeab 100644
--- a/library/cpp/threading/task_scheduler/task_scheduler_ut.cpp
+++ b/library/cpp/threading/task_scheduler/task_scheduler_ut.cpp
@@ -1,86 +1,86 @@
-#include <algorithm>
+#include <algorithm>
#include <library/cpp/testing/unittest/registar.h>
-
+
#include <util/stream/output.h>
#include <util/system/atomic.h>
#include <util/generic/vector.h>
-
+
#include "task_scheduler.h"
-
-class TTaskSchedulerTest: public TTestBase {
- UNIT_TEST_SUITE(TTaskSchedulerTest);
- UNIT_TEST(Test);
- UNIT_TEST_SUITE_END();
-
+
+class TTaskSchedulerTest: public TTestBase {
+ UNIT_TEST_SUITE(TTaskSchedulerTest);
+ UNIT_TEST(Test);
+ UNIT_TEST_SUITE_END();
+
class TCheckTask: public TTaskScheduler::IRepeatedTask {
- public:
+ public:
TCheckTask(const TDuration& delay)
: Start_(Now())
, Delay_(delay)
- {
+ {
AtomicIncrement(ScheduledTaskCounter_);
- }
-
+ }
+
~TCheckTask() override {
- }
-
+ }
+
bool Process() override {
const TDuration delay = Now() - Start_;
-
+
if (delay < Delay_) {
AtomicIncrement(BadTimeoutCounter_);
- }
-
+ }
+
AtomicIncrement(ExecutedTaskCounter_);
return false;
- }
-
- static bool AllTaskExecuted() {
+ }
+
+ static bool AllTaskExecuted() {
return AtomicGet(ScheduledTaskCounter_) == AtomicGet(ExecutedTaskCounter_);
- }
-
- static size_t BadTimeoutCount() {
+ }
+
+ static size_t BadTimeoutCount() {
return AtomicGet(BadTimeoutCounter_);
- }
-
- private:
+ }
+
+ private:
TInstant Start_;
TDuration Delay_;
static TAtomic BadTimeoutCounter_;
static TAtomic ScheduledTaskCounter_;
static TAtomic ExecutedTaskCounter_;
- };
-
- public:
- inline void Test() {
- ScheduleCheckTask(200);
- ScheduleCheckTask(100);
- ScheduleCheckTask(1000);
- ScheduleCheckTask(10000);
- ScheduleCheckTask(5000);
-
+ };
+
+ public:
+ inline void Test() {
+ ScheduleCheckTask(200);
+ ScheduleCheckTask(100);
+ ScheduleCheckTask(1000);
+ ScheduleCheckTask(10000);
+ ScheduleCheckTask(5000);
+
Scheduler_.Start();
-
- usleep(1000000);
-
- UNIT_ASSERT_EQUAL(TCheckTask::BadTimeoutCount(), 0);
- UNIT_ASSERT(TCheckTask::AllTaskExecuted());
- }
-
- private:
- void ScheduleCheckTask(size_t delay) {
+
+ usleep(1000000);
+
+ UNIT_ASSERT_EQUAL(TCheckTask::BadTimeoutCount(), 0);
+ UNIT_ASSERT(TCheckTask::AllTaskExecuted());
+ }
+
+ private:
+ void ScheduleCheckTask(size_t delay) {
TDuration d = TDuration::MicroSeconds(delay);
Scheduler_.Add(new TCheckTask(d), d);
- }
-
- private:
+ }
+
+ private:
TTaskScheduler Scheduler_;
-};
-
+};
+
TAtomic TTaskSchedulerTest::TCheckTask::BadTimeoutCounter_ = 0;
TAtomic TTaskSchedulerTest::TCheckTask::ScheduledTaskCounter_ = 0;
TAtomic TTaskSchedulerTest::TCheckTask::ExecutedTaskCounter_ = 0;
-
-UNIT_TEST_SUITE_REGISTRATION(TTaskSchedulerTest);
+
+UNIT_TEST_SUITE_REGISTRATION(TTaskSchedulerTest);