From 3979d32fa672147515f863df38b86708488c2e06 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Mon, 28 Jan 2019 13:11:17 -0500 Subject: [PATCH] rgw: add make_throttle() for optionally-async AioThrottle Signed-off-by: Casey Bodley --- src/rgw/rgw_aio_throttle.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/rgw/rgw_aio_throttle.h b/src/rgw/rgw_aio_throttle.h index 613abb534b0..19baae6cbb2 100644 --- a/src/rgw/rgw_aio_throttle.h +++ b/src/rgw/rgw_aio_throttle.h @@ -19,6 +19,7 @@ #include #include "common/ceph_mutex.h" #include "common/async/completion.h" +#include "common/async/yield_context.h" #include "services/svc_rados.h" #include "rgw_aio.h" @@ -113,4 +114,22 @@ class YieldingAioThrottle final : public Aio, private Throttle { }; #endif // HAVE_BOOST_CONTEXT +// return a smart pointer to Aio +inline auto make_throttle(uint64_t window_size, optional_yield y) +{ +#ifdef HAVE_BOOST_CONTEXT + std::unique_ptr aio; + if (y) { + aio = std::make_unique(window_size, + y.get_io_context(), + y.get_yield_context()); + } else { + aio = std::make_unique(window_size); + } + return aio; +#else + return std::make_optional(window_size); +#endif +} + } // namespace rgw -- 2.39.5