diff options
author | pechatnov <pechatnov@yandex-team.ru> | 2022-02-10 16:48:57 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:57 +0300 |
commit | 132a3640fac343164b858d0a914e020a848a2848 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/threading/future/core/future-inl.h | |
parent | 8e9b2f8bbf4a2320f539eef5b85555f42c065425 (diff) | |
download | ydb-132a3640fac343164b858d0a914e020a848a2848.tar.gz |
Restoring authorship annotation for <pechatnov@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 | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/library/cpp/threading/future/core/future-inl.h b/library/cpp/threading/future/core/future-inl.h index d9bd32a21e..5fd4296a93 100644 --- a/library/cpp/threading/future/core/future-inl.h +++ b/library/cpp/threading/future/core/future-inl.h @@ -127,21 +127,21 @@ namespace NThreading { template <typename TT> void SetValue(TT&& value) { - bool success = TrySetValue(std::forward<TT>(value)); - if (Y_UNLIKELY(!success)) { - ythrow TFutureException() << "value already set"; - } - } - - template <typename TT> - bool TrySetValue(TT&& value) { + bool success = TrySetValue(std::forward<TT>(value)); + if (Y_UNLIKELY(!success)) { + ythrow TFutureException() << "value already set"; + } + } + + template <typename TT> + bool TrySetValue(TT&& value) { TSystemEvent* readyEvent = nullptr; TCallbackList<T> callbacks; with_lock (StateLock) { int state = AtomicGet(State); if (Y_UNLIKELY(state != NotReady)) { - return false; + return false; } new (&Value) T(std::forward<TT>(value)); @@ -162,8 +162,8 @@ namespace NThreading { callback(temp); } } - - return true; + + return true; } void SetException(std::exception_ptr e) { @@ -316,20 +316,20 @@ namespace NThreading { } void SetValue() { - bool success = TrySetValue(); - if (Y_UNLIKELY(!success)) { - ythrow TFutureException() << "value already set"; - } - } - - bool TrySetValue() { + bool success = TrySetValue(); + if (Y_UNLIKELY(!success)) { + ythrow TFutureException() << "value already set"; + } + } + + bool TrySetValue() { TSystemEvent* readyEvent = nullptr; TCallbackList<void> callbacks; with_lock (StateLock) { int state = AtomicGet(State); if (Y_UNLIKELY(state != NotReady)) { - return false; + return false; } readyEvent = ReadyEvent.Get(); @@ -348,8 +348,8 @@ namespace NThreading { callback(temp); } } - - return true; + + return true; } void SetException(std::exception_ptr e) { @@ -798,18 +798,18 @@ namespace NThreading { } template <typename T> - inline bool TPromise<T>::TrySetValue(const T& value) { - EnsureInitialized(); - return State->TrySetValue(value); - } - - template <typename T> - inline bool TPromise<T>::TrySetValue(T&& value) { - EnsureInitialized(); - return State->TrySetValue(std::move(value)); - } - - template <typename T> + inline bool TPromise<T>::TrySetValue(const T& value) { + EnsureInitialized(); + return State->TrySetValue(value); + } + + template <typename T> + inline bool TPromise<T>::TrySetValue(T&& value) { + EnsureInitialized(); + return State->TrySetValue(std::move(value)); + } + + template <typename T> inline void TPromise<T>::TryRethrow() const { if (State) { State->TryRethrow(); @@ -887,11 +887,11 @@ namespace NThreading { State->SetValue(); } - inline bool TPromise<void>::TrySetValue() { - EnsureInitialized(); - return State->TrySetValue(); - } - + inline bool TPromise<void>::TrySetValue() { + EnsureInitialized(); + return State->TrySetValue(); + } + inline void TPromise<void>::TryRethrow() const { if(State) { State->TryRethrow(); |