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 | eb540cc7a103419462d0cc870ca403966e2194c6 (patch) | |
tree | c0748b5dcbade83af788c0abfa89c0383d6b779c /library/cpp/threading/future/core/future-inl.h | |
parent | 80f0a6b4102e3b2c89f23935c7690409033ea24c (diff) | |
download | ydb-eb540cc7a103419462d0cc870ca403966e2194c6.tar.gz |
Restoring authorship annotation for <asorotsky@yandex-team.ru>. Commit 2 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 3973b9c170..5fd4296a93 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)}; |