diff options
| author | asorotsky <[email protected]> | 2022-02-10 16:47:33 +0300 |
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:47:33 +0300 |
| commit | eb540cc7a103419462d0cc870ca403966e2194c6 (patch) | |
| tree | c0748b5dcbade83af788c0abfa89c0383d6b779c /library/cpp/threading/future/core | |
| parent | 80f0a6b4102e3b2c89f23935c7690409033ea24c (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/threading/future/core')
| -rw-r--r-- | library/cpp/threading/future/core/future-inl.h | 46 | ||||
| -rw-r--r-- | library/cpp/threading/future/core/future.h | 4 |
2 files changed, 25 insertions, 25 deletions
diff --git a/library/cpp/threading/future/core/future-inl.h b/library/cpp/threading/future/core/future-inl.h index 3973b9c1703..5fd4296a93c 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 b8442f94c65..2e82bb953eb 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(); //////////////////////////////////////////////////////////////////////////////// |
