diff options
author | asorotsky <asorotsky@yandex-team.ru> | 2022-02-10 16:47:33 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:33 +0300 |
commit | 80f0a6b4102e3b2c89f23935c7690409033ea24c (patch) | |
tree | d37ae19cf2360516f71e010c02f3fd8fc6b22999 /library/cpp/threading/future/core/future-inl.h | |
parent | 9f1d4466bb653173233b0e47d2cbda7f46995f92 (diff) | |
download | ydb-80f0a6b4102e3b2c89f23935c7690409033ea24c.tar.gz |
Restoring authorship annotation for <asorotsky@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/threading/future/core/future-inl.h')
-rw-r--r-- | library/cpp/threading/future/core/future-inl.h | 46 |
1 files changed, 23 insertions, 23 deletions
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)}; |