From: Casey Bodley Date: Mon, 28 Jan 2019 18:11:17 +0000 (-0500) Subject: rgw: add make_throttle() for optionally-async AioThrottle X-Git-Tag: v15.1.0~2838^2~6 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=3979d32fa672147515f863df38b86708488c2e06;p=ceph-ci.git rgw: add make_throttle() for optionally-async AioThrottle Signed-off-by: Casey Bodley --- 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