aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/threading
diff options
context:
space:
mode:
authorarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-04-02 01:14:13 +0300
committerarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-04-02 01:14:13 +0300
commit6754a6a379c0522676071b52818018c46b0a8e58 (patch)
tree7106cb31d3cd22eb6a7bb4bbde47ae23cd9f4027 /library/cpp/threading
parent24e1d4fe6d126ac368719f6a98bb4192739adb05 (diff)
downloadydb-6754a6a379c0522676071b52818018c46b0a8e58.tar.gz
intermediate changes
ref:4f6264c5be27540a15fdefdc0e4084f35b9f7f44
Diffstat (limited to 'library/cpp/threading')
-rw-r--r--library/cpp/threading/future/core/future-inl.h30
-rw-r--r--library/cpp/threading/future/core/future.cpp6
2 files changed, 22 insertions, 14 deletions
diff --git a/library/cpp/threading/future/core/future-inl.h b/library/cpp/threading/future/core/future-inl.h
index 5fd4296a93..d04fd54e29 100644
--- a/library/cpp/threading/future/core/future-inl.h
+++ b/library/cpp/threading/future/core/future-inl.h
@@ -16,6 +16,8 @@ namespace NThreading {
////////////////////////////////////////////////////////////////////////////////
+ [[noreturn]] void ThrowFutureException(TStringBuf message, const TSourceLocation& source);
+
enum class TError {
Error
};
@@ -48,11 +50,11 @@ namespace NThreading {
int state = AtomicGet(State);
if (Y_UNLIKELY(state == NotReady)) {
if (timeout == TDuration::Zero()) {
- ythrow TFutureException() << "value not set";
+ ::NThreading::NImpl::ThrowFutureException("value not set"sv, __LOCATION__);
}
if (!Wait(timeout)) {
- ythrow TFutureException() << "wait timeout";
+ ::NThreading::NImpl::ThrowFutureException("wait timeout"sv, __LOCATION__);
}
state = AtomicGet(State);
@@ -65,11 +67,11 @@ namespace NThreading {
break;
case ValueRead:
if (acquireState != ValueRead) {
- ythrow TFutureException() << "value being read";
+ ::NThreading::NImpl::ThrowFutureException("value being read"sv, __LOCATION__);
}
break;
case ValueMoved:
- ythrow TFutureException() << "value was moved";
+ ::NThreading::NImpl::ThrowFutureException("value was moved"sv, __LOCATION__);
default:
Y_ASSERT(state == ValueSet);
}
@@ -129,7 +131,7 @@ namespace NThreading {
void SetValue(TT&& value) {
bool success = TrySetValue(std::forward<TT>(value));
if (Y_UNLIKELY(!success)) {
- ythrow TFutureException() << "value already set";
+ ::NThreading::NImpl::ThrowFutureException("value already set"sv, __LOCATION__);
}
}
@@ -169,7 +171,7 @@ namespace NThreading {
void SetException(std::exception_ptr e) {
bool success = TrySetException(std::move(e));
if (Y_UNLIKELY(!success)) {
- ythrow TFutureException() << "value already set";
+ ::NThreading::NImpl::ThrowFutureException("value already set"sv, __LOCATION__);
}
}
@@ -300,11 +302,11 @@ namespace NThreading {
int state = AtomicGet(State);
if (Y_UNLIKELY(state == NotReady)) {
if (timeout == TDuration::Zero()) {
- ythrow TFutureException() << "value not set";
+ ::NThreading::NImpl::ThrowFutureException("value not set"sv, __LOCATION__);
}
if (!Wait(timeout)) {
- ythrow TFutureException() << "wait timeout";
+ ::NThreading::NImpl::ThrowFutureException("wait timeout"sv, __LOCATION__);
}
state = AtomicGet(State);
@@ -318,7 +320,7 @@ namespace NThreading {
void SetValue() {
bool success = TrySetValue();
if (Y_UNLIKELY(!success)) {
- ythrow TFutureException() << "value already set";
+ ::NThreading::NImpl::ThrowFutureException("value already set"sv, __LOCATION__);
}
}
@@ -355,7 +357,7 @@ namespace NThreading {
void SetException(std::exception_ptr e) {
bool success = TrySetException(std::move(e));
if (Y_UNLIKELY(!success)) {
- ythrow TFutureException() << "value already set";
+ ::NThreading::NImpl::ThrowFutureException("value already set"sv, __LOCATION__);
}
}
@@ -649,7 +651,7 @@ namespace NThreading {
template <typename T>
inline void TFuture<T>::EnsureInitialized() const {
if (!State) {
- ythrow TFutureException() << "state not initialized";
+ ::NThreading::NImpl::ThrowFutureException("state not initialized"sv, __LOCATION__);
}
}
@@ -751,7 +753,7 @@ namespace NThreading {
inline void TFuture<void>::EnsureInitialized() const {
if (!State) {
- ythrow TFutureException() << "state not initialized";
+ ::NThreading::NImpl::ThrowFutureException("state not initialized"sv, __LOCATION__);
}
}
@@ -858,7 +860,7 @@ namespace NThreading {
template <typename T>
inline void TPromise<T>::EnsureInitialized() const {
if (!State) {
- ythrow TFutureException() << "state not initialized";
+ ::NThreading::NImpl::ThrowFutureException("state not initialized"sv, __LOCATION__);
}
}
@@ -932,7 +934,7 @@ namespace NThreading {
inline void TPromise<void>::EnsureInitialized() const {
if (!State) {
- ythrow TFutureException() << "state not initialized";
+ ::NThreading::NImpl::ThrowFutureException("state not initialized"sv, __LOCATION__);
}
}
diff --git a/library/cpp/threading/future/core/future.cpp b/library/cpp/threading/future/core/future.cpp
index 3243afcb40..809369d843 100644
--- a/library/cpp/threading/future/core/future.cpp
+++ b/library/cpp/threading/future/core/future.cpp
@@ -1 +1,7 @@
#include "future.h"
+
+namespace NThreading::NImpl {
+ [[noreturn]] void ThrowFutureException(TStringBuf message, const TSourceLocation& source) {
+ throw source + TFutureException() << message;
+ }
+}