aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/threading/future/core
diff options
context:
space:
mode:
authorpechatnov <pechatnov@yandex-team.ru>2022-02-10 16:48:57 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:57 +0300
commit132a3640fac343164b858d0a914e020a848a2848 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/threading/future/core
parent8e9b2f8bbf4a2320f539eef5b85555f42c065425 (diff)
downloadydb-132a3640fac343164b858d0a914e020a848a2848.tar.gz
Restoring authorship annotation for <pechatnov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/threading/future/core')
-rw-r--r--library/cpp/threading/future/core/future-inl.h76
-rw-r--r--library/cpp/threading/future/core/future.h8
2 files changed, 42 insertions, 42 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();
diff --git a/library/cpp/threading/future/core/future.h b/library/cpp/threading/future/core/future.h
index b42a83a4ca..2e82bb953e 100644
--- a/library/cpp/threading/future/core/future.h
+++ b/library/cpp/threading/future/core/future.h
@@ -209,9 +209,9 @@ namespace NThreading {
void SetValue(const T& value);
void SetValue(T&& value);
- bool TrySetValue(const T& value);
- bool TrySetValue(T&& value);
-
+ bool TrySetValue(const T& value);
+ bool TrySetValue(T&& value);
+
void TryRethrow() const;
bool HasException() const;
void SetException(const TString& e);
@@ -250,7 +250,7 @@ namespace NThreading {
void GetValue() const;
void SetValue();
- bool TrySetValue();
+ bool TrySetValue();
void TryRethrow() const;
bool HasException() const;