feat update
This commit is contained in:
parent
a10703176c
commit
d8c5807af6
@ -25,15 +25,15 @@ struct JustSender {
|
|||||||
template<typename R>
|
template<typename R>
|
||||||
JustOperation<T, R> Connect(R receiver)
|
JustOperation<T, R> Connect(R receiver)
|
||||||
{
|
{
|
||||||
return {value, receiver};
|
return {std::forward<T>(value), receiver};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
JustSender<T>
|
JustSender<T>
|
||||||
Just(T value)
|
Just(T &&value)
|
||||||
{
|
{
|
||||||
return {value};
|
return {std::forward<T>(value)};
|
||||||
}
|
}
|
||||||
|
|
||||||
}// namespace detail
|
}// namespace detail
|
||||||
|
@ -13,12 +13,12 @@ struct ThenReceiver {
|
|||||||
F func;
|
F func;
|
||||||
bool stopped = false;
|
bool stopped = false;
|
||||||
|
|
||||||
template<typename U>
|
template<typename U, typename Ret = invoke_result_t<F, U>>
|
||||||
void SetValue(U &&val)
|
void SetValue(U &&val)
|
||||||
{
|
{
|
||||||
if (stopped) { return; }
|
if (stopped) { return; }
|
||||||
try {
|
try {
|
||||||
receiver.SetValue(func(std::forward<U>(val)));
|
receiver.SetValue(std::forward<Ret>(func(std::forward<U>(val))));
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
SetError(std::current_exception());
|
SetError(std::current_exception());
|
||||||
}
|
}
|
||||||
@ -49,7 +49,7 @@ struct ThenOperation {
|
|||||||
|
|
||||||
template<typename S, typename F>
|
template<typename S, typename F>
|
||||||
struct ThenSender {
|
struct ThenSender {
|
||||||
using result_t = invoke_result_t<F, typename S::result_t>;
|
using result_t = invoke_result_t<F, typename decay_t<S>::result_t>;
|
||||||
S sender;
|
S sender;
|
||||||
F func;
|
F func;
|
||||||
|
|
||||||
@ -62,9 +62,9 @@ struct ThenSender {
|
|||||||
|
|
||||||
template<typename S, typename F>
|
template<typename S, typename F>
|
||||||
ThenSender<S, F>
|
ThenSender<S, F>
|
||||||
Then(S sender, F &&func)
|
Then(S &&sender, F &&func)
|
||||||
{
|
{
|
||||||
return {sender, std::forward<F>(func)};
|
return {std::forward<S>(sender), std::forward<F>(func)};
|
||||||
}
|
}
|
||||||
|
|
||||||
}// namespace detail
|
}// namespace detail
|
||||||
|
@ -18,6 +18,9 @@ using ConnectResultT = typename ConnectResult<S, R>::type;
|
|||||||
template<typename F, typename... Args>
|
template<typename F, typename... Args>
|
||||||
using invoke_result_t = eggs::invoke_result_t<F, Args...>;
|
using invoke_result_t = eggs::invoke_result_t<F, Args...>;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
using decay_t = typename std::decay<T>::type;
|
||||||
|
|
||||||
}// namespace detail
|
}// namespace detail
|
||||||
}// namespace sled
|
}// namespace sled
|
||||||
#endif// SLED_FUTURES_DETAIL_TRAITS_H
|
#endif// SLED_FUTURES_DETAIL_TRAITS_H
|
||||||
|
Loading…
Reference in New Issue
Block a user