aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/threading
diff options
context:
space:
mode:
authorrzhikharevich <rzhikharevich@yandex-team.ru>2022-02-10 16:51:00 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:51:00 +0300
commit724861a587a9d8ecec238aec4c37154e3f2409bb (patch)
tree4efb7811cde0cc9f95a48040cc3a9b26775c6dae /library/cpp/threading
parent7b34adcce01173502f056f3a5053d8ca47945b76 (diff)
downloadydb-724861a587a9d8ecec238aec4c37154e3f2409bb.tar.gz
Restoring authorship annotation for <rzhikharevich@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/threading')
-rw-r--r--library/cpp/threading/future/core/future-inl.h8
-rw-r--r--library/cpp/threading/future/future_ut.cpp158
2 files changed, 83 insertions, 83 deletions
diff --git a/library/cpp/threading/future/core/future-inl.h b/library/cpp/threading/future/core/future-inl.h
index 5fd4296a93..e0ddd4295e 100644
--- a/library/cpp/threading/future/core/future-inl.h
+++ b/library/cpp/threading/future/core/future-inl.h
@@ -621,8 +621,8 @@ namespace NThreading {
template <typename F>
inline TFuture<TFutureType<TFutureCallResult<F, T>>> TFuture<T>::Apply(F&& func) const {
auto promise = NewPromise<TFutureType<TFutureCallResult<F, T>>>();
- Subscribe([promise, func = std::forward<F>(func)](const TFuture<T>& future) mutable {
- NImpl::SetValue(promise, [&]() { return func(future); });
+ Subscribe([promise, func = std::forward<F>(func)](const TFuture<T>& future) mutable {
+ NImpl::SetValue(promise, [&]() { return func(future); });
});
return promise;
}
@@ -720,8 +720,8 @@ namespace NThreading {
template <typename F>
inline TFuture<TFutureType<TFutureCallResult<F, void>>> TFuture<void>::Apply(F&& func) const {
auto promise = NewPromise<TFutureType<TFutureCallResult<F, void>>>();
- Subscribe([promise, func = std::forward<F>(func)](const TFuture<void>& future) mutable {
- NImpl::SetValue(promise, [&]() { return func(future); });
+ Subscribe([promise, func = std::forward<F>(func)](const TFuture<void>& future) mutable {
+ NImpl::SetValue(promise, [&]() { return func(future); });
});
return promise;
}
diff --git a/library/cpp/threading/future/future_ut.cpp b/library/cpp/threading/future/future_ut.cpp
index 05950a568d..ccc214372d 100644
--- a/library/cpp/threading/future/future_ut.cpp
+++ b/library/cpp/threading/future/future_ut.cpp
@@ -9,32 +9,32 @@ namespace NThreading {
namespace {
- class TCopyCounter {
- public:
- TCopyCounter(size_t* numCopies)
- : NumCopies(numCopies)
- {}
-
- TCopyCounter(const TCopyCounter& that)
- : NumCopies(that.NumCopies)
- {
- ++*NumCopies;
- }
-
- TCopyCounter& operator=(const TCopyCounter& that) {
- NumCopies = that.NumCopies;
- ++*NumCopies;
- return *this;
- }
-
- TCopyCounter(TCopyCounter&& that) = default;
-
- TCopyCounter& operator=(TCopyCounter&& that) = default;
-
- private:
- size_t* NumCopies = nullptr;
- };
-
+ class TCopyCounter {
+ public:
+ TCopyCounter(size_t* numCopies)
+ : NumCopies(numCopies)
+ {}
+
+ TCopyCounter(const TCopyCounter& that)
+ : NumCopies(that.NumCopies)
+ {
+ ++*NumCopies;
+ }
+
+ TCopyCounter& operator=(const TCopyCounter& that) {
+ NumCopies = that.NumCopies;
+ ++*NumCopies;
+ return *this;
+ }
+
+ TCopyCounter(TCopyCounter&& that) = default;
+
+ TCopyCounter& operator=(TCopyCounter&& that) = default;
+
+ private:
+ size_t* NumCopies = nullptr;
+ };
+
template <typename T>
auto MakePromise() {
if constexpr (std::is_same_v<T, void>) {
@@ -582,59 +582,59 @@ namespace {
TestFutureStateId<void>();
TestFutureStateId<int>();
}
-
- template <typename T>
- void TestApplyNoRvalueCopyImpl() {
- size_t numCopies = 0;
- TCopyCounter copyCounter(&numCopies);
-
- auto promise = MakePromise<T>();
-
- const auto future = promise.GetFuture().Apply(
- [copyCounter = std::move(copyCounter)] (const auto&) {}
- );
-
- if constexpr (std::is_same_v<T, void>) {
- promise.SetValue();
- } else {
- promise.SetValue(T());
- }
-
- future.GetValueSync();
-
- UNIT_ASSERT_VALUES_EQUAL(numCopies, 0);
- }
-
- Y_UNIT_TEST(ApplyNoRvalueCopy) {
- TestApplyNoRvalueCopyImpl<void>();
- TestApplyNoRvalueCopyImpl<int>();
- }
-
- template <typename T>
- void TestApplyLvalueCopyImpl() {
- size_t numCopies = 0;
- TCopyCounter copyCounter(&numCopies);
-
- auto promise = MakePromise<T>();
-
- auto func = [copyCounter = std::move(copyCounter)] (const auto&) {};
- const auto future = promise.GetFuture().Apply(func);
-
- if constexpr (std::is_same_v<T, void>) {
- promise.SetValue();
- } else {
- promise.SetValue(T());
- }
-
- future.GetValueSync();
-
- UNIT_ASSERT_VALUES_EQUAL(numCopies, 1);
- }
-
- Y_UNIT_TEST(ApplyLvalueCopy) {
- TestApplyLvalueCopyImpl<void>();
- TestApplyLvalueCopyImpl<int>();
- }
+
+ template <typename T>
+ void TestApplyNoRvalueCopyImpl() {
+ size_t numCopies = 0;
+ TCopyCounter copyCounter(&numCopies);
+
+ auto promise = MakePromise<T>();
+
+ const auto future = promise.GetFuture().Apply(
+ [copyCounter = std::move(copyCounter)] (const auto&) {}
+ );
+
+ if constexpr (std::is_same_v<T, void>) {
+ promise.SetValue();
+ } else {
+ promise.SetValue(T());
+ }
+
+ future.GetValueSync();
+
+ UNIT_ASSERT_VALUES_EQUAL(numCopies, 0);
+ }
+
+ Y_UNIT_TEST(ApplyNoRvalueCopy) {
+ TestApplyNoRvalueCopyImpl<void>();
+ TestApplyNoRvalueCopyImpl<int>();
+ }
+
+ template <typename T>
+ void TestApplyLvalueCopyImpl() {
+ size_t numCopies = 0;
+ TCopyCounter copyCounter(&numCopies);
+
+ auto promise = MakePromise<T>();
+
+ auto func = [copyCounter = std::move(copyCounter)] (const auto&) {};
+ const auto future = promise.GetFuture().Apply(func);
+
+ if constexpr (std::is_same_v<T, void>) {
+ promise.SetValue();
+ } else {
+ promise.SetValue(T());
+ }
+
+ future.GetValueSync();
+
+ UNIT_ASSERT_VALUES_EQUAL(numCopies, 1);
+ }
+
+ Y_UNIT_TEST(ApplyLvalueCopy) {
+ TestApplyLvalueCopyImpl<void>();
+ TestApplyLvalueCopyImpl<int>();
+ }
}
}