diff options
author | AlexSm <alex@ydb.tech> | 2023-12-27 23:31:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-27 23:31:58 +0100 |
commit | d67bfb4b4b7549081543e87a31bc6cb5c46ac973 (patch) | |
tree | 8674f2f1570877cb653e7ddcff37ba00288de15a /library/cpp/threading/future/core | |
parent | 1f6bef05ed441c3aa2d565ac792b26cded704ac7 (diff) | |
download | ydb-d67bfb4b4b7549081543e87a31bc6cb5c46ac973.tar.gz |
Import libs 4 (#758)
Diffstat (limited to 'library/cpp/threading/future/core')
-rw-r--r-- | library/cpp/threading/future/core/future-inl.h | 8 | ||||
-rw-r--r-- | library/cpp/threading/future/core/future.h | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/library/cpp/threading/future/core/future-inl.h b/library/cpp/threading/future/core/future-inl.h index a98175af2d..db58b3156c 100644 --- a/library/cpp/threading/future/core/future-inl.h +++ b/library/cpp/threading/future/core/future-inl.h @@ -729,16 +729,16 @@ namespace NThreading { } template <typename R> - inline TFuture<R> TFuture<void>::Return(const R& value) const { - auto promise = NewPromise<R>(); - Subscribe([=](const TFuture<void>& future) mutable { + inline TFuture<std::remove_cvref_t<R>> TFuture<void>::Return(R&& value) const { + auto promise = NewPromise<std::remove_cvref_t<R>>(); + Subscribe([promise, value = std::forward<R>(value)](const TFuture<void>& future) mutable { try { future.TryRethrow(); } catch (...) { promise.SetException(std::current_exception()); return; } - promise.SetValue(value); + promise.SetValue(std::move(value)); }); return promise; } diff --git a/library/cpp/threading/future/core/future.h b/library/cpp/threading/future/core/future.h index c803b28b75..598336282a 100644 --- a/library/cpp/threading/future/core/future.h +++ b/library/cpp/threading/future/core/future.h @@ -169,7 +169,7 @@ namespace NThreading { TFuture<TFutureType<TFutureCallResult<F, void>>> Apply(F&& func) const; template <typename R> - TFuture<R> Return(const R& value) const; + TFuture<std::remove_cvref_t<R>> Return(R&& value) const; TFuture<void> IgnoreResult() const { return *this; |