aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/threading/future
diff options
context:
space:
mode:
authoreeight <eeight@yandex-team.ru>2022-02-10 16:46:19 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:46:19 +0300
commitbd085aee9b4f7a0bee302ce687964ffb7098f986 (patch)
tree1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /library/cpp/threading/future
parent475c0a46f28166e83fd263badc7546377cddcabe (diff)
downloadydb-bd085aee9b4f7a0bee302ce687964ffb7098f986.tar.gz
Restoring authorship annotation for <eeight@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/threading/future')
-rw-r--r--library/cpp/threading/future/async.h4
-rw-r--r--library/cpp/threading/future/async_ut.cpp4
-rw-r--r--library/cpp/threading/future/legacy_future.h8
-rw-r--r--library/cpp/threading/future/legacy_future_ut.cpp8
-rw-r--r--library/cpp/threading/future/wait/wait-inl.h26
-rw-r--r--library/cpp/threading/future/wait/wait.cpp50
-rw-r--r--library/cpp/threading/future/wait/wait.h28
7 files changed, 64 insertions, 64 deletions
diff --git a/library/cpp/threading/future/async.h b/library/cpp/threading/future/async.h
index a7e84cc29b..8543fdd5c6 100644
--- a/library/cpp/threading/future/async.h
+++ b/library/cpp/threading/future/async.h
@@ -3,7 +3,7 @@
#include "future.h"
#include <util/generic/function.h>
-#include <util/thread/pool.h>
+#include <util/thread/pool.h>
namespace NThreading {
/**
@@ -18,7 +18,7 @@ namespace NThreading {
* unittest.
*/
template <typename Func>
- TFuture<TFutureType<TFunctionResult<Func>>> Async(Func&& func, IThreadPool& queue) {
+ TFuture<TFutureType<TFunctionResult<Func>>> Async(Func&& func, IThreadPool& queue) {
auto promise = NewPromise<TFutureType<TFunctionResult<Func>>>();
auto lambda = [promise, func = std::forward<Func>(func)]() mutable {
NImpl::SetValue(promise, func);
diff --git a/library/cpp/threading/future/async_ut.cpp b/library/cpp/threading/future/async_ut.cpp
index 6901ed2621..a3699744e4 100644
--- a/library/cpp/threading/future/async_ut.cpp
+++ b/library/cpp/threading/future/async_ut.cpp
@@ -36,7 +36,7 @@ Y_UNIT_TEST_SUITE(Async) {
}
Y_UNIT_TEST(WorksWithIMtpQueue) {
- auto queue = MakeHolder<TThreadPool>();
+ auto queue = MakeHolder<TThreadPool>();
queue->Start(1);
auto future = NThreading::Async([]() { return 5; }, *queue);
@@ -46,7 +46,7 @@ Y_UNIT_TEST_SUITE(Async) {
Y_UNIT_TEST(ProperlyDeducesFutureType) {
// Compileability test
- auto queue = CreateThreadPool(1);
+ auto queue = CreateThreadPool(1);
NThreading::TFuture<void> f1 = NThreading::Async([]() {}, *queue);
NThreading::TFuture<int> f2 = NThreading::Async([]() { return 5; }, *queue);
diff --git a/library/cpp/threading/future/legacy_future.h b/library/cpp/threading/future/legacy_future.h
index 5240f92992..6f1eabad73 100644
--- a/library/cpp/threading/future/legacy_future.h
+++ b/library/cpp/threading/future/legacy_future.h
@@ -3,13 +3,13 @@
#include "fwd.h"
#include "future.h"
-#include <util/thread/factory.h>
+#include <util/thread/factory.h>
#include <functional>
namespace NThreading {
template <typename TR, bool IgnoreException>
- class TLegacyFuture: public IThreadFactory::IThreadAble, TNonCopyable {
+ class TLegacyFuture: public IThreadFactory::IThreadAble, TNonCopyable {
public:
typedef TR(TFunctionSignature)();
using TFunctionObjectType = std::function<TFunctionSignature>;
@@ -18,10 +18,10 @@ namespace NThreading {
private:
TFunctionObjectType Func_;
TPromise<TResult> Result_;
- THolder<IThreadFactory::IThread> Thread_;
+ THolder<IThreadFactory::IThread> Thread_;
public:
- inline TLegacyFuture(const TFunctionObjectType func, IThreadFactory* pool = SystemThreadFactory())
+ inline TLegacyFuture(const TFunctionObjectType func, IThreadFactory* pool = SystemThreadFactory())
: Func_(func)
, Result_(NewPromise<TResult>())
, Thread_(pool->Run(this))
diff --git a/library/cpp/threading/future/legacy_future_ut.cpp b/library/cpp/threading/future/legacy_future_ut.cpp
index 873c913d82..ff63db1725 100644
--- a/library/cpp/threading/future/legacy_future_ut.cpp
+++ b/library/cpp/threading/future/legacy_future_ut.cpp
@@ -43,7 +43,7 @@ namespace NThreading {
TLegacyFuture<int> f11(std::bind(&TSampleClass::Calc, TSampleClass(3)));
UNIT_ASSERT_VALUES_EQUAL(4, f11.Get());
- TLegacyFuture<int> f12(std::bind(&TSampleClass::Calc, TSampleClass(3)), SystemThreadFactory());
+ TLegacyFuture<int> f12(std::bind(&TSampleClass::Calc, TSampleClass(3)), SystemThreadFactory());
UNIT_ASSERT_VALUES_EQUAL(4, f12.Get());
TSampleClass c(5);
@@ -51,17 +51,17 @@ namespace NThreading {
TLegacyFuture<int> f21(std::bind(&TSampleClass::Calc, std::ref(c)));
UNIT_ASSERT_VALUES_EQUAL(6, f21.Get());
- TLegacyFuture<int> f22(std::bind(&TSampleClass::Calc, std::ref(c)), SystemThreadFactory());
+ TLegacyFuture<int> f22(std::bind(&TSampleClass::Calc, std::ref(c)), SystemThreadFactory());
UNIT_ASSERT_VALUES_EQUAL(6, f22.Get());
}
- struct TSomeThreadPool: public IThreadFactory {};
+ struct TSomeThreadPool: public IThreadFactory {};
Y_UNIT_TEST(TestFunction) {
std::function<int()> f((&intf));
UNIT_ASSERT_VALUES_EQUAL(17, TLegacyFuture<int>(f).Get());
- UNIT_ASSERT_VALUES_EQUAL(17, TLegacyFuture<int>(f, SystemThreadFactory()).Get());
+ UNIT_ASSERT_VALUES_EQUAL(17, TLegacyFuture<int>(f, SystemThreadFactory()).Get());
if (false) {
TSomeThreadPool* q = nullptr;
diff --git a/library/cpp/threading/future/wait/wait-inl.h b/library/cpp/threading/future/wait/wait-inl.h
index a80b65a933..2753d5446c 100644
--- a/library/cpp/threading/future/wait/wait-inl.h
+++ b/library/cpp/threading/future/wait/wait-inl.h
@@ -6,31 +6,31 @@
namespace NThreading {
namespace NImpl {
- template <typename TContainer>
- TVector<TFuture<void>> ToVoidFutures(const TContainer& futures) {
- TVector<TFuture<void>> voidFutures;
- voidFutures.reserve(futures.size());
+ template <typename TContainer>
+ TVector<TFuture<void>> ToVoidFutures(const TContainer& futures) {
+ TVector<TFuture<void>> voidFutures;
+ voidFutures.reserve(futures.size());
- for (const auto& future: futures) {
- voidFutures.push_back(future.IgnoreResult());
+ for (const auto& future: futures) {
+ voidFutures.push_back(future.IgnoreResult());
}
- return voidFutures;
+ return voidFutures;
}
}
template <typename TContainer>
- [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAll(const TContainer& futures) {
- return WaitAll(NImpl::ToVoidFutures(futures));
+ [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAll(const TContainer& futures) {
+ return WaitAll(NImpl::ToVoidFutures(futures));
}
template <typename TContainer>
- [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitExceptionOrAll(const TContainer& futures) {
- return WaitExceptionOrAll(NImpl::ToVoidFutures(futures));
+ [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitExceptionOrAll(const TContainer& futures) {
+ return WaitExceptionOrAll(NImpl::ToVoidFutures(futures));
}
template <typename TContainer>
- [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAny(const TContainer& futures) {
- return WaitAny(NImpl::ToVoidFutures(futures));
+ [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAny(const TContainer& futures) {
+ return WaitAny(NImpl::ToVoidFutures(futures));
}
}
diff --git a/library/cpp/threading/future/wait/wait.cpp b/library/cpp/threading/future/wait/wait.cpp
index cc33f3189c..a173833a7f 100644
--- a/library/cpp/threading/future/wait/wait.cpp
+++ b/library/cpp/threading/future/wait/wait.cpp
@@ -1,17 +1,17 @@
-#include "wait.h"
+#include "wait.h"
#include "wait_group.h"
#include "wait_policy.h"
namespace NThreading {
- namespace {
+ namespace {
template <class WaitPolicy>
- TFuture<void> WaitGeneric(const TFuture<void>& f1) {
+ TFuture<void> WaitGeneric(const TFuture<void>& f1) {
return f1;
}
template <class WaitPolicy>
- TFuture<void> WaitGeneric(const TFuture<void>& f1, const TFuture<void>& f2) {
+ TFuture<void> WaitGeneric(const TFuture<void>& f1, const TFuture<void>& f2) {
TWaitGroup<WaitPolicy> wg;
wg.Add(f1).Add(f2);
@@ -19,13 +19,13 @@ namespace NThreading {
return std::move(wg).Finish();
}
- template <class WaitPolicy>
- TFuture<void> WaitGeneric(TArrayRef<const TFuture<void>> futures) {
+ template <class WaitPolicy>
+ TFuture<void> WaitGeneric(TArrayRef<const TFuture<void>> futures) {
if (futures.empty()) {
return MakeFuture();
}
if (futures.size() == 1) {
- return futures.front();
+ return futures.front();
}
TWaitGroup<WaitPolicy> wg;
@@ -39,44 +39,44 @@ namespace NThreading {
////////////////////////////////////////////////////////////////////////////////
- TFuture<void> WaitAll(const TFuture<void>& f1) {
- return WaitGeneric<TWaitPolicy::TAll>(f1);
+ TFuture<void> WaitAll(const TFuture<void>& f1) {
+ return WaitGeneric<TWaitPolicy::TAll>(f1);
}
- TFuture<void> WaitAll(const TFuture<void>& f1, const TFuture<void>& f2) {
- return WaitGeneric<TWaitPolicy::TAll>(f1, f2);
+ TFuture<void> WaitAll(const TFuture<void>& f1, const TFuture<void>& f2) {
+ return WaitGeneric<TWaitPolicy::TAll>(f1, f2);
}
- TFuture<void> WaitAll(TArrayRef<const TFuture<void>> futures) {
- return WaitGeneric<TWaitPolicy::TAll>(futures);
+ TFuture<void> WaitAll(TArrayRef<const TFuture<void>> futures) {
+ return WaitGeneric<TWaitPolicy::TAll>(futures);
}
////////////////////////////////////////////////////////////////////////////////
- TFuture<void> WaitExceptionOrAll(const TFuture<void>& f1) {
- return WaitGeneric<TWaitPolicy::TExceptionOrAll>(f1);
+ TFuture<void> WaitExceptionOrAll(const TFuture<void>& f1) {
+ return WaitGeneric<TWaitPolicy::TExceptionOrAll>(f1);
}
- TFuture<void> WaitExceptionOrAll(const TFuture<void>& f1, const TFuture<void>& f2) {
- return WaitGeneric<TWaitPolicy::TExceptionOrAll>(f1, f2);
+ TFuture<void> WaitExceptionOrAll(const TFuture<void>& f1, const TFuture<void>& f2) {
+ return WaitGeneric<TWaitPolicy::TExceptionOrAll>(f1, f2);
}
- TFuture<void> WaitExceptionOrAll(TArrayRef<const TFuture<void>> futures) {
- return WaitGeneric<TWaitPolicy::TExceptionOrAll>(futures);
+ TFuture<void> WaitExceptionOrAll(TArrayRef<const TFuture<void>> futures) {
+ return WaitGeneric<TWaitPolicy::TExceptionOrAll>(futures);
}
////////////////////////////////////////////////////////////////////////////////
- TFuture<void> WaitAny(const TFuture<void>& f1) {
- return WaitGeneric<TWaitPolicy::TAny>(f1);
+ TFuture<void> WaitAny(const TFuture<void>& f1) {
+ return WaitGeneric<TWaitPolicy::TAny>(f1);
}
- TFuture<void> WaitAny(const TFuture<void>& f1, const TFuture<void>& f2) {
- return WaitGeneric<TWaitPolicy::TAny>(f1, f2);
+ TFuture<void> WaitAny(const TFuture<void>& f1, const TFuture<void>& f2) {
+ return WaitGeneric<TWaitPolicy::TAny>(f1, f2);
}
- TFuture<void> WaitAny(TArrayRef<const TFuture<void>> futures) {
- return WaitGeneric<TWaitPolicy::TAny>(futures);
+ TFuture<void> WaitAny(TArrayRef<const TFuture<void>> futures) {
+ return WaitGeneric<TWaitPolicy::TAny>(futures);
}
}
diff --git a/library/cpp/threading/future/wait/wait.h b/library/cpp/threading/future/wait/wait.h
index ade4c9a3ad..6ff7d57baa 100644
--- a/library/cpp/threading/future/wait/wait.h
+++ b/library/cpp/threading/future/wait/wait.h
@@ -5,35 +5,35 @@
#include <library/cpp/threading/future/core/future.h>
#include <library/cpp/threading/future/wait/wait_group.h>
-#include <util/generic/array_ref.h>
-
+#include <util/generic/array_ref.h>
+
namespace NThreading {
- namespace NImpl {
- template <class TContainer>
- using EnableGenericWait = std::enable_if_t<
- !std::is_convertible_v<TContainer, TArrayRef<const TFuture<void>>>,
- TFuture<void>>;
- }
+ namespace NImpl {
+ template <class TContainer>
+ using EnableGenericWait = std::enable_if_t<
+ !std::is_convertible_v<TContainer, TArrayRef<const TFuture<void>>>,
+ TFuture<void>>;
+ }
// waits for all futures
[[nodiscard]] TFuture<void> WaitAll(const TFuture<void>& f1);
[[nodiscard]] TFuture<void> WaitAll(const TFuture<void>& f1, const TFuture<void>& f2);
- [[nodiscard]] TFuture<void> WaitAll(TArrayRef<const TFuture<void>> futures);
+ [[nodiscard]] TFuture<void> WaitAll(TArrayRef<const TFuture<void>> futures);
template <typename TContainer>
- [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAll(const TContainer& futures);
+ [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAll(const TContainer& futures);
// waits for the first exception or for all futures
[[nodiscard]] TFuture<void> WaitExceptionOrAll(const TFuture<void>& f1);
[[nodiscard]] TFuture<void> WaitExceptionOrAll(const TFuture<void>& f1, const TFuture<void>& f2);
- [[nodiscard]] TFuture<void> WaitExceptionOrAll(TArrayRef<const TFuture<void>> futures);
+ [[nodiscard]] TFuture<void> WaitExceptionOrAll(TArrayRef<const TFuture<void>> futures);
template <typename TContainer>
- [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitExceptionOrAll(const TContainer& futures);
+ [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitExceptionOrAll(const TContainer& futures);
// waits for any future
[[nodiscard]] TFuture<void> WaitAny(const TFuture<void>& f1);
[[nodiscard]] TFuture<void> WaitAny(const TFuture<void>& f1, const TFuture<void>& f2);
- [[nodiscard]] TFuture<void> WaitAny(TArrayRef<const TFuture<void>> futures);
+ [[nodiscard]] TFuture<void> WaitAny(TArrayRef<const TFuture<void>> futures);
template <typename TContainer>
- [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAny(const TContainer& futures);
+ [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAny(const TContainer& futures);
}
#define INCLUDE_FUTURE_INL_H