mirror of
https://github.com/ceph/ceph
synced 2025-02-14 22:37:51 +00:00
Merge pull request #43247 from rzarzynski/wip-crimson-ertr-safe_then_unpack
crimson/common: add safe_then_unpack() to errorated futures Reviewed-by: Samuel Just <sjust@redhat.com> Reviewed-by: Chunmei Liu <chunmei.liu@intel.com>
This commit is contained in:
commit
86b9f03094
@ -8,6 +8,7 @@
|
||||
|
||||
#include <seastar/core/future-util.hh>
|
||||
|
||||
#include "crimson/common/utility.h"
|
||||
#include "include/ceph_assert.h"
|
||||
|
||||
namespace crimson::interruptible {
|
||||
@ -667,6 +668,19 @@ private:
|
||||
errorator_type::pass_further{});
|
||||
}
|
||||
|
||||
template <class ValueFunc,
|
||||
class... ErrorFuncs>
|
||||
auto safe_then_unpack(ValueFunc&& value_func,
|
||||
ErrorFuncs&&... error_funcs) {
|
||||
return safe_then(
|
||||
[value_func=std::move(value_func)] (ValueT&& tuple) mutable {
|
||||
assert_moveable(value_func);
|
||||
return std::apply(std::move(value_func), std::move(tuple));
|
||||
},
|
||||
std::forward<ErrorFuncs>(error_funcs)...
|
||||
);
|
||||
}
|
||||
|
||||
template <class Func>
|
||||
void then(Func&&) = delete;
|
||||
|
||||
|
@ -5,12 +5,16 @@
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace _impl {
|
||||
template <class T> struct always_false : std::false_type {};
|
||||
};
|
||||
|
||||
template <class T>
|
||||
void assert_moveable(T& t) {
|
||||
// It's fine
|
||||
}
|
||||
template <class T>
|
||||
void assert_moveable(const T& t) {
|
||||
static_assert(always_false<T>::value, "unable to move-out from T");
|
||||
static_assert(_impl::always_false<T>::value, "unable to move-out from T");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user