mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-26 03:20:37 +00:00
future: add futurize::make_exception_future()
Add a way to create an exceptional future of a type that is not directly known.
This commit is contained in:
@@ -509,6 +509,10 @@ struct futurize {
|
||||
/// and return the result, as a future (if it wasn't already).
|
||||
template<typename Func, typename... FuncArgs>
|
||||
static inline type apply(Func&& func, FuncArgs&&... args);
|
||||
|
||||
/// Makes an exceptional future of type \ref type.
|
||||
template <typename Arg>
|
||||
static type make_exception_future(Arg&& arg);
|
||||
};
|
||||
|
||||
/// \cond internal
|
||||
@@ -522,6 +526,9 @@ struct futurize<void> {
|
||||
|
||||
template<typename Func, typename... FuncArgs>
|
||||
static inline type apply(Func&& func, FuncArgs&&... args);
|
||||
|
||||
template <typename Arg>
|
||||
static type make_exception_future(Arg&& arg);
|
||||
};
|
||||
|
||||
template <typename... Args>
|
||||
@@ -534,6 +541,9 @@ struct futurize<future<Args...>> {
|
||||
|
||||
template<typename Func, typename... FuncArgs>
|
||||
static inline type apply(Func&& func, FuncArgs&&... args);
|
||||
|
||||
template <typename Arg>
|
||||
static type make_exception_future(Arg&& arg);
|
||||
};
|
||||
/// \endcond
|
||||
|
||||
@@ -967,6 +977,29 @@ typename futurize<future<Args...>>::type futurize<future<Args...>>::apply(Func&&
|
||||
return func(std::forward<FuncArgs>(args)...);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
template <typename Arg>
|
||||
inline
|
||||
future<T>
|
||||
futurize<T>::make_exception_future(Arg&& arg) {
|
||||
return ::make_exception_future<T>(std::forward<Arg>(arg));
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
template <typename Arg>
|
||||
inline
|
||||
future<T...>
|
||||
futurize<future<T...>>::make_exception_future(Arg&& arg) {
|
||||
return ::make_exception_future<T...>(std::forward<Arg>(arg));
|
||||
}
|
||||
|
||||
template <typename Arg>
|
||||
inline
|
||||
future<>
|
||||
futurize<void>::make_exception_future(Arg&& arg) {
|
||||
return ::make_exception_future<>(std::forward<Arg>(arg));
|
||||
}
|
||||
|
||||
/// \endcond
|
||||
|
||||
#endif /* FUTURE_HH_ */
|
||||
|
||||
Reference in New Issue
Block a user