aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/threading
diff options
context:
space:
mode:
authorasorotsky <asorotsky@yandex-team.ru>2022-02-10 16:47:33 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:33 +0300
commit80f0a6b4102e3b2c89f23935c7690409033ea24c (patch)
treed37ae19cf2360516f71e010c02f3fd8fc6b22999 /library/cpp/threading
parent9f1d4466bb653173233b0e47d2cbda7f46995f92 (diff)
downloadydb-80f0a6b4102e3b2c89f23935c7690409033ea24c.tar.gz
Restoring authorship annotation for <asorotsky@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/threading')
-rw-r--r--library/cpp/threading/chunk_queue/queue.h16
-rw-r--r--library/cpp/threading/future/core/future-inl.h46
-rw-r--r--library/cpp/threading/future/core/future.h4
-rw-r--r--library/cpp/threading/future/future_ut.cpp66
-rw-r--r--library/cpp/threading/future/wait/wait-inl.h2
-rw-r--r--library/cpp/threading/future/wait/wait.cpp2
-rw-r--r--library/cpp/threading/future/wait/wait.h4
7 files changed, 70 insertions, 70 deletions
diff --git a/library/cpp/threading/chunk_queue/queue.h b/library/cpp/threading/chunk_queue/queue.h
index 55859601a1..311222e4dc 100644
--- a/library/cpp/threading/chunk_queue/queue.h
+++ b/library/cpp/threading/chunk_queue/queue.h
@@ -34,14 +34,14 @@ namespace NThreading {
static_assert(sizeof(*this) % PadSize == 0, "padding does not work");
Y_UNUSED(Pad);
}
-
- template<typename... Args>
- TPadded(Args&&... args)
- : T(std::forward<Args>(args)...)
- {
- static_assert(sizeof(*this) % PadSize == 0, "padding does not work");
- Y_UNUSED(Pad);
- }
+
+ template<typename... Args>
+ TPadded(Args&&... args)
+ : T(std::forward<Args>(args)...)
+ {
+ static_assert(sizeof(*this) % PadSize == 0, "padding does not work");
+ Y_UNUSED(Pad);
+ }
};
////////////////////////////////////////////////////////////////////////////////
diff --git a/library/cpp/threading/future/core/future-inl.h b/library/cpp/threading/future/core/future-inl.h
index 5fd4296a93..3973b9c170 100644
--- a/library/cpp/threading/future/core/future-inl.h
+++ b/library/cpp/threading/future/core/future-inl.h
@@ -16,10 +16,10 @@ namespace NThreading {
////////////////////////////////////////////////////////////////////////////////
- enum class TError {
- Error
- };
-
+ enum class TError {
+ Error
+ };
+
template <typename T>
class TFutureState: public TAtomicRefCount<TFutureState<T>> {
enum {
@@ -89,13 +89,13 @@ namespace NThreading {
{
}
- TFutureState(std::exception_ptr exception, TError)
- : State(ExceptionSet)
- , Exception(std::move(exception))
- , NullValue(0)
- {
- }
-
+ TFutureState(std::exception_ptr exception, TError)
+ : State(ExceptionSet)
+ , Exception(std::move(exception))
+ , NullValue(0)
+ {
+ }
+
~TFutureState() {
if (State >= ValueMoved) { // ValueMoved, ValueSet, ValueRead
Value.~T();
@@ -277,12 +277,12 @@ namespace NThreading {
{
}
- TFutureState(std::exception_ptr exception, TError)
- : State(ExceptionSet)
- , Exception(std::move(exception))
- {
- }
-
+ TFutureState(std::exception_ptr exception, TError)
+ : State(ExceptionSet)
+ , Exception(std::move(exception))
+ {
+ }
+
bool HasValue() const {
return AtomicGet(State) == ValueSet;
}
@@ -971,12 +971,12 @@ namespace NThreading {
return Singleton<TCache>()->Instance;
}
- template <typename T>
- inline TFuture<T> MakeErrorFuture(std::exception_ptr exception)
- {
- return {new NImpl::TFutureState<T>(std::move(exception), NImpl::TError::Error)};
- }
-
+ template <typename T>
+ inline TFuture<T> MakeErrorFuture(std::exception_ptr exception)
+ {
+ return {new NImpl::TFutureState<T>(std::move(exception), NImpl::TError::Error)};
+ }
+
inline TFuture<void> MakeFuture() {
struct TCache {
TFuture<void> Instance{new NImpl::TFutureState<void>(true)};
diff --git a/library/cpp/threading/future/core/future.h b/library/cpp/threading/future/core/future.h
index 2e82bb953e..b8442f94c6 100644
--- a/library/cpp/threading/future/core/future.h
+++ b/library/cpp/threading/future/core/future.h
@@ -28,8 +28,8 @@ namespace NThreading {
TFuture<std::remove_reference_t<T>> MakeFuture(T&& value);
template <typename T>
TFuture<T> MakeFuture();
- template <typename T>
- TFuture<T> MakeErrorFuture(std::exception_ptr exception);
+ template <typename T>
+ TFuture<T> MakeErrorFuture(std::exception_ptr exception);
TFuture<void> MakeFuture();
////////////////////////////////////////////////////////////////////////////////
diff --git a/library/cpp/threading/future/future_ut.cpp b/library/cpp/threading/future/future_ut.cpp
index 05950a568d..f44272bef0 100644
--- a/library/cpp/threading/future/future_ut.cpp
+++ b/library/cpp/threading/future/future_ut.cpp
@@ -281,17 +281,17 @@ namespace {
TVector<TFuture<void>> promises;
promises.push_back(promise1);
promises.push_back(promise2);
-
+
TFuture<void> future = WaitExceptionOrAll(promises);
UNIT_ASSERT(!future.HasValue());
-
+
promise1.SetValue();
UNIT_ASSERT(!future.HasValue());
-
+
promise2.SetValue();
UNIT_ASSERT(future.HasValue());
}
-
+
Y_UNIT_TEST(ShouldWaitExceptionOrAllVectorWithValueType) {
TPromise<int> promise1 = NewPromise<int>();
TPromise<int> promise2 = NewPromise<int>();
@@ -313,7 +313,7 @@ namespace {
Y_UNIT_TEST(ShouldWaitExceptionOrAllList) {
TPromise<void> promise1 = NewPromise();
TPromise<void> promise2 = NewPromise();
-
+
std::list<TFuture<void>> promises;
promises.push_back(promise1);
promises.push_back(promise2);
@@ -334,25 +334,25 @@ namespace {
TFuture<void> future = WaitExceptionOrAll(promises);
UNIT_ASSERT(future.HasValue());
}
-
+
Y_UNIT_TEST(ShouldWaitAnyVector) {
TPromise<void> promise1 = NewPromise();
TPromise<void> promise2 = NewPromise();
-
+
TVector<TFuture<void>> promises;
promises.push_back(promise1);
promises.push_back(promise2);
-
+
TFuture<void> future = WaitAny(promises);
UNIT_ASSERT(!future.HasValue());
-
+
promise1.SetValue();
UNIT_ASSERT(future.HasValue());
-
+
promise2.SetValue();
UNIT_ASSERT(future.HasValue());
}
-
+
Y_UNIT_TEST(ShouldWaitAnyVectorWithValueType) {
TPromise<int> promise1 = NewPromise<int>();
@@ -375,7 +375,7 @@ namespace {
Y_UNIT_TEST(ShouldWaitAnyList) {
TPromise<void> promise1 = NewPromise();
TPromise<void> promise2 = NewPromise();
-
+
std::list<TFuture<void>> promises;
promises.push_back(promise1);
promises.push_back(promise2);
@@ -396,11 +396,11 @@ namespace {
TFuture<void> future = WaitAny(promises);
UNIT_ASSERT(future.HasValue());
}
-
+
Y_UNIT_TEST(ShouldWaitAny) {
TPromise<void> promise1 = NewPromise();
TPromise<void> promise2 = NewPromise();
-
+
TFuture<void> future = WaitAny(promise1, promise2);
UNIT_ASSERT(!future.HasValue());
@@ -506,7 +506,7 @@ namespace {
UNIT_ASSERT(promise.TrySetValue(42));
UNIT_ASSERT(!promise.TrySetValue(42));
}
-
+
Y_UNIT_TEST(HandlingRepetitiveSetException) {
TPromise<int> promise = NewPromise<int>();
promise.SetException("test");
@@ -519,24 +519,24 @@ namespace {
UNIT_ASSERT(!promise.TrySetException(std::make_exception_ptr("test")));
}
- Y_UNIT_TEST(ShouldAllowToMakeFutureWithException)
- {
- auto future1 = MakeErrorFuture<void>(std::make_exception_ptr(TFutureException()));
- UNIT_ASSERT(future1.HasException());
- UNIT_CHECK_GENERATED_EXCEPTION(future1.GetValue(), TFutureException);
-
- auto future2 = MakeErrorFuture<int>(std::make_exception_ptr(TFutureException()));
- UNIT_ASSERT(future2.HasException());
- UNIT_CHECK_GENERATED_EXCEPTION(future2.GetValue(), TFutureException);
-
- auto future3 = MakeFuture<std::exception_ptr>(std::make_exception_ptr(TFutureException()));
- UNIT_ASSERT(future3.HasValue());
- UNIT_CHECK_GENERATED_NO_EXCEPTION(future3.GetValue(), TFutureException);
-
- auto future4 = MakeFuture<std::unique_ptr<int>>(nullptr);
- UNIT_ASSERT(future4.HasValue());
- UNIT_CHECK_GENERATED_NO_EXCEPTION(future4.GetValue(), TFutureException);
- }
+ Y_UNIT_TEST(ShouldAllowToMakeFutureWithException)
+ {
+ auto future1 = MakeErrorFuture<void>(std::make_exception_ptr(TFutureException()));
+ UNIT_ASSERT(future1.HasException());
+ UNIT_CHECK_GENERATED_EXCEPTION(future1.GetValue(), TFutureException);
+
+ auto future2 = MakeErrorFuture<int>(std::make_exception_ptr(TFutureException()));
+ UNIT_ASSERT(future2.HasException());
+ UNIT_CHECK_GENERATED_EXCEPTION(future2.GetValue(), TFutureException);
+
+ auto future3 = MakeFuture<std::exception_ptr>(std::make_exception_ptr(TFutureException()));
+ UNIT_ASSERT(future3.HasValue());
+ UNIT_CHECK_GENERATED_NO_EXCEPTION(future3.GetValue(), TFutureException);
+
+ auto future4 = MakeFuture<std::unique_ptr<int>>(nullptr);
+ UNIT_ASSERT(future4.HasValue());
+ UNIT_CHECK_GENERATED_NO_EXCEPTION(future4.GetValue(), TFutureException);
+ }
Y_UNIT_TEST(WaitAllowsExtract) {
auto future = MakeFuture<int>(42);
diff --git a/library/cpp/threading/future/wait/wait-inl.h b/library/cpp/threading/future/wait/wait-inl.h
index 2753d5446c..1803ab3dcc 100644
--- a/library/cpp/threading/future/wait/wait-inl.h
+++ b/library/cpp/threading/future/wait/wait-inl.h
@@ -28,7 +28,7 @@ namespace NThreading {
[[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));
diff --git a/library/cpp/threading/future/wait/wait.cpp b/library/cpp/threading/future/wait/wait.cpp
index a173833a7f..c84d9864af 100644
--- a/library/cpp/threading/future/wait/wait.cpp
+++ b/library/cpp/threading/future/wait/wait.cpp
@@ -65,7 +65,7 @@ namespace NThreading {
TFuture<void> WaitExceptionOrAll(TArrayRef<const TFuture<void>> futures) {
return WaitGeneric<TWaitPolicy::TExceptionOrAll>(futures);
}
-
+
////////////////////////////////////////////////////////////////////////////////
TFuture<void> WaitAny(const TFuture<void>& f1) {
diff --git a/library/cpp/threading/future/wait/wait.h b/library/cpp/threading/future/wait/wait.h
index 6ff7d57baa..493fe34298 100644
--- a/library/cpp/threading/future/wait/wait.h
+++ b/library/cpp/threading/future/wait/wait.h
@@ -29,8 +29,8 @@ namespace NThreading {
[[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(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);
template <typename TContainer>
[[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAny(const TContainer& futures);