diff options
author | kikht <kikht@yandex-team.ru> | 2022-02-10 16:45:14 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:14 +0300 |
commit | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (patch) | |
tree | be835aa92c6248212e705f25388ebafcf84bc7a1 /library/cpp/threading | |
parent | 194cae0e8855b11be2005e1eff12c660c3ee9774 (diff) | |
download | ydb-778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5.tar.gz |
Restoring authorship annotation for <kikht@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/threading')
-rw-r--r-- | library/cpp/threading/future/core/future-inl.h | 62 | ||||
-rw-r--r-- | library/cpp/threading/future/core/future.h | 4 | ||||
-rw-r--r-- | library/cpp/threading/future/future_ut.cpp | 24 |
3 files changed, 45 insertions, 45 deletions
diff --git a/library/cpp/threading/future/core/future-inl.h b/library/cpp/threading/future/core/future-inl.h index 7f44059a01..5fd4296a93 100644 --- a/library/cpp/threading/future/core/future-inl.h +++ b/library/cpp/threading/future/core/future-inl.h @@ -167,20 +167,20 @@ namespace NThreading { } void SetException(std::exception_ptr e) { - bool success = TrySetException(std::move(e)); - if (Y_UNLIKELY(!success)) { - ythrow TFutureException() << "value already set"; - } - } - - bool TrySetException(std::exception_ptr e) { + bool success = TrySetException(std::move(e)); + if (Y_UNLIKELY(!success)) { + ythrow TFutureException() << "value already set"; + } + } + + bool TrySetException(std::exception_ptr e) { TSystemEvent* readyEvent; TCallbackList<T> callbacks; with_lock (StateLock) { int state = AtomicGet(State); if (Y_UNLIKELY(state != NotReady)) { - return false; + return false; } Exception = std::move(e); @@ -201,8 +201,8 @@ namespace NThreading { callback(temp); } } - - return true; + + return true; } template <typename F> @@ -353,20 +353,20 @@ namespace NThreading { } void SetException(std::exception_ptr e) { - bool success = TrySetException(std::move(e)); - if (Y_UNLIKELY(!success)) { - ythrow TFutureException() << "value already set"; - } - } - - bool TrySetException(std::exception_ptr e) { + bool success = TrySetException(std::move(e)); + if (Y_UNLIKELY(!success)) { + ythrow TFutureException() << "value already set"; + } + } + + bool TrySetException(std::exception_ptr e) { TSystemEvent* readyEvent = nullptr; TCallbackList<void> callbacks; with_lock (StateLock) { int state = AtomicGet(State); if (Y_UNLIKELY(state != NotReady)) { - return false; + return false; } Exception = std::move(e); @@ -387,8 +387,8 @@ namespace NThreading { callback(temp); } } - - return true; + + return true; } template <typename F> @@ -834,12 +834,12 @@ namespace NThreading { } template <typename T> - inline bool TPromise<T>::TrySetException(std::exception_ptr e) { - EnsureInitialized(); - return State->TrySetException(std::move(e)); - } - - template <typename T> + inline bool TPromise<T>::TrySetException(std::exception_ptr e) { + EnsureInitialized(); + return State->TrySetException(std::move(e)); + } + + template <typename T> inline TFuture<T> TPromise<T>::GetFuture() const { EnsureInitialized(); return TFuture<T>(State); @@ -912,11 +912,11 @@ namespace NThreading { State->SetException(std::move(e)); } - inline bool TPromise<void>::TrySetException(std::exception_ptr e) { - EnsureInitialized(); - return State->TrySetException(std::move(e)); - } - + inline bool TPromise<void>::TrySetException(std::exception_ptr e) { + EnsureInitialized(); + return State->TrySetException(std::move(e)); + } + inline TFuture<void> TPromise<void>::GetFuture() const { EnsureInitialized(); return TFuture<void>(State); diff --git a/library/cpp/threading/future/core/future.h b/library/cpp/threading/future/core/future.h index a4a1012352..2e82bb953e 100644 --- a/library/cpp/threading/future/core/future.h +++ b/library/cpp/threading/future/core/future.h @@ -216,7 +216,7 @@ namespace NThreading { bool HasException() const; void SetException(const TString& e); void SetException(std::exception_ptr e); - bool TrySetException(std::exception_ptr e); + bool TrySetException(std::exception_ptr e); TFuture<T> GetFuture() const; operator TFuture<T>() const; @@ -256,7 +256,7 @@ namespace NThreading { bool HasException() const; void SetException(const TString& e); void SetException(std::exception_ptr e); - bool TrySetException(std::exception_ptr e); + bool TrySetException(std::exception_ptr e); TFuture<void> GetFuture() const; operator TFuture<void>() const; diff --git a/library/cpp/threading/future/future_ut.cpp b/library/cpp/threading/future/future_ut.cpp index 63fb4604be..05950a568d 100644 --- a/library/cpp/threading/future/future_ut.cpp +++ b/library/cpp/threading/future/future_ut.cpp @@ -507,18 +507,18 @@ namespace { UNIT_ASSERT(!promise.TrySetValue(42)); } - Y_UNIT_TEST(HandlingRepetitiveSetException) { - TPromise<int> promise = NewPromise<int>(); - promise.SetException("test"); - UNIT_CHECK_GENERATED_EXCEPTION(promise.SetException("test"), TFutureException); - } - - Y_UNIT_TEST(HandlingRepetitiveTrySetException) { - TPromise<int> promise = NewPromise<int>(); - UNIT_ASSERT(promise.TrySetException(std::make_exception_ptr("test"))); - UNIT_ASSERT(!promise.TrySetException(std::make_exception_ptr("test"))); - } - + Y_UNIT_TEST(HandlingRepetitiveSetException) { + TPromise<int> promise = NewPromise<int>(); + promise.SetException("test"); + UNIT_CHECK_GENERATED_EXCEPTION(promise.SetException("test"), TFutureException); + } + + Y_UNIT_TEST(HandlingRepetitiveTrySetException) { + TPromise<int> promise = NewPromise<int>(); + UNIT_ASSERT(promise.TrySetException(std::make_exception_ptr("test"))); + UNIT_ASSERT(!promise.TrySetException(std::make_exception_ptr("test"))); + } + Y_UNIT_TEST(ShouldAllowToMakeFutureWithException) { auto future1 = MakeErrorFuture<void>(std::make_exception_ptr(TFutureException())); |