aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/threading
diff options
context:
space:
mode:
authorAlexey Efimov <xeno@prnwatch.com>2022-02-10 16:49:42 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:42 +0300
commit0fd1998e1b2369f50fb694556f817d3c7fef10c8 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/threading
parent26e0e4fb5e5cd6b4d7f4c21f9fcd7978891bf946 (diff)
downloadydb-0fd1998e1b2369f50fb694556f817d3c7fef10c8.tar.gz
Restoring authorship annotation for Alexey Efimov <xeno@prnwatch.com>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/threading')
-rw-r--r--library/cpp/threading/future/core/future-inl.h22
-rw-r--r--library/cpp/threading/future/future_ut.cpp14
2 files changed, 18 insertions, 18 deletions
diff --git a/library/cpp/threading/future/core/future-inl.h b/library/cpp/threading/future/core/future-inl.h
index b67d79e3010..5fd4296a93c 100644
--- a/library/cpp/threading/future/core/future-inl.h
+++ b/library/cpp/threading/future/core/future-inl.h
@@ -73,22 +73,22 @@ namespace NThreading {
default:
Y_ASSERT(state == ValueSet);
}
- }
-
+ }
+
public:
TFutureState()
: State(NotReady)
, NullValue(0)
{
- }
-
+ }
+
template <typename TT>
TFutureState(TT&& value)
: State(ValueSet)
, Value(std::forward<TT>(value))
{
}
-
+
TFutureState(std::exception_ptr exception, TError)
: State(ExceptionSet)
, Exception(std::move(exception))
@@ -101,11 +101,11 @@ namespace NThreading {
Value.~T();
}
}
-
+
bool HasValue() const {
return AtomicGet(State) >= ValueMoved; // ValueMoved, ValueSet, ValueRead
- }
-
+ }
+
void TryRethrow() const {
int state = AtomicGet(State);
TryRethrowWithState(state);
@@ -148,7 +148,7 @@ namespace NThreading {
readyEvent = ReadyEvent.Get();
callbacks = std::move(Callbacks);
-
+
AtomicSet(State, ValueSet);
}
@@ -635,7 +635,7 @@ namespace NThreading {
});
return promise;
}
-
+
template <typename T>
inline bool TFuture<T>::Initialized() const {
return bool(State);
@@ -790,7 +790,7 @@ namespace NThreading {
EnsureInitialized();
State->SetValue(value);
}
-
+
template <typename T>
inline void TPromise<T>::SetValue(T&& value) {
EnsureInitialized();
diff --git a/library/cpp/threading/future/future_ut.cpp b/library/cpp/threading/future/future_ut.cpp
index 8dc87880866..05950a568d4 100644
--- a/library/cpp/threading/future/future_ut.cpp
+++ b/library/cpp/threading/future/future_ut.cpp
@@ -447,15 +447,15 @@ namespace {
explicit TRec(int) {
}
};
-
+
auto promise = NewPromise<TRec>();
promise.SetValue(TRec(1));
-
+
auto future = MakeFuture(TRec(1));
auto rec = future.ExtractValue();
Y_UNUSED(rec);
}
-
+
Y_UNIT_TEST(ShouldNotExtractAfterGet) {
TPromise<int> promise = NewPromise<int>();
promise.SetValue(123);
@@ -463,7 +463,7 @@ namespace {
UNIT_ASSERT_EQUAL(promise.GetValue(), 123);
UNIT_CHECK_GENERATED_EXCEPTION(promise.ExtractValue(), TFutureException);
}
-
+
Y_UNIT_TEST(ShouldNotGetAfterExtract) {
TPromise<int> promise = NewPromise<int>();
promise.SetValue(123);
@@ -471,7 +471,7 @@ namespace {
UNIT_ASSERT_EQUAL(promise.ExtractValue(), 123);
UNIT_CHECK_GENERATED_EXCEPTION(promise.GetValue(), TFutureException);
}
-
+
Y_UNIT_TEST(ShouldNotExtractAfterExtract) {
TPromise<int> promise = NewPromise<int>();
promise.SetValue(123);
@@ -635,6 +635,6 @@ namespace {
TestApplyLvalueCopyImpl<void>();
TestApplyLvalueCopyImpl<int>();
}
- }
-
+ }
+
}