while (true) {
auto f = futurator::invoke(action);
- if (!seastar::need_preempt() && f.available() && std::get<0>(f.get())) {
+ if (!seastar::need_preempt() && f.available() && f.get()) {
return futurator::type::errorator_type::template make_ready_future<>();
}
if (!f.available() || seastar::need_preempt()) {
// solution here would be mark the `::get_available_state()`
// as `protected` and use dedicated `get_value()` exactly as
// `::then()` already does.
- return futurator_t::apply(std::forward<ValueFuncT>(valfunc),
- std::move(future).get());
+ return futurator_t::invoke(std::forward<ValueFuncT>(valfunc),
+ std::move(future).get());
}
});
}
class futurize {
using vanilla_futurize = seastar::futurize<T>;
- template <class...>
- struct tuple2future {};
- template <class... Args>
- struct tuple2future <std::tuple<Args...>> {
- using type = future<Args...>;
+ template <class Stored, int Dummy = 0>
+ struct stored_to_future {
+ using type = future<Stored>;
+ };
+ template <int Dummy>
+ struct stored_to_future <seastar::internal::monostate, Dummy> {
+ using type = future<>;
};
public:
using type =
- typename tuple2future<typename vanilla_futurize::value_type>::type;
+ typename stored_to_future<typename vanilla_futurize::value_type>::type;
template <class Func, class... Args>
- static type apply(Func&& func, std::tuple<Args...>&& args) {
- return vanilla_futurize::apply(std::forward<Func>(func),
- std::forward<std::tuple<Args...>>(args));
+ static type invoke(Func&& func, Args&&... args) {
+ try {
+ return vanilla_futurize::invoke(std::forward<Func>(func),
+ std::forward<Args>(args)...);
+ } catch (...) {
+ return make_exception_future(std::current_exception());
+ }
+ }
+
+ template <class Func>
+ static type invoke(Func&& func, seastar::internal::monostate) {
+ try {
+ return vanilla_futurize::invoke(std::forward<Func>(func));
+ } catch (...) {
+ return make_exception_future(std::current_exception());
+ }
}
template <typename Arg>
}
}
+ template <class Func, class... Args>
+ static type invoke(Func&& func, Args&&... args) {
+ try {
+ return ::seastar::futurize_invoke(std::forward<Func>(func),
+ std::forward<Args>(args)...);
+ } catch (...) {
+ return make_exception_future(std::current_exception());
+ }
+ }
+
+ template <class Func>
+ static type invoke(Func&& func, seastar::internal::monostate) {
+ try {
+ return ::seastar::futurize_invoke(std::forward<Func>(func));
+ } catch (...) {
+ return make_exception_future(std::current_exception());
+ }
+ }
+
template <typename Arg>
static type make_exception_future(Arg&& arg) {
return ::crimson::errorator<AllowedErrors...>::make_exception_future2<ValuesT...>(std::forward<Arg>(arg));
template<typename Func, typename... FuncArgs>
[[gnu::always_inline]]
- static inline type apply(Func&& func, std::tuple<FuncArgs...>&& args) noexcept {
- try {
- return std::apply(std::forward<Func>(func),
- std::forward<std::tuple<FuncArgs...>>(args));
- } catch (...) {
- return make_exception_future(std::current_exception());
- }
- }
-
- template<typename Func, typename... FuncArgs>
static inline type invoke(Func&& func, FuncArgs&&... args) noexcept {
try {
return func(std::forward<FuncArgs>(args)...);