From 01fff77895454b2b3ff9199f974246455316f821 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Sun, 29 Sep 2019 15:02:38 +0200 Subject: [PATCH] crimson: specialize seastar::futurize to avoid copying. Signed-off-by: Radoslaw Zarzynski --- src/crimson/common/errorator.h | 171 ++++++++++++++++++++++++-------- src/crimson/osd/ops_executer.cc | 6 +- 2 files changed, 131 insertions(+), 46 deletions(-) diff --git a/src/crimson/common/errorator.h b/src/crimson/common/errorator.h index a9d9718f440..fa532cd69dc 100644 --- a/src/crimson/common/errorator.h +++ b/src/crimson/common/errorator.h @@ -275,6 +275,9 @@ static constexpr auto composer(FuncHead&& head, FuncTail&&... tail) { }; } +template +struct errorated_future_marker{}; + template struct errorator { template @@ -298,8 +301,13 @@ struct errorator { static_assert((... && contains_once_v), "no error type in errorator can be duplicated"); +private: + // see the comment for `using future = _future` below. + template + class _future {}; template - class future : private seastar::future { + class _future<::crimson::errorated_future_marker> + : private seastar::future { using base_t = seastar::future; // we need the friendship for the sake of `get_exception() &&` when // `safe_then()` is going to return an errorated future as a result of @@ -362,16 +370,18 @@ struct errorator { using errorator_type = ::crimson::errorator; [[gnu::always_inline]] - future(base_t&& base) + _future(base_t&& base) : base_t(std::move(base)) { } template