]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add make_throttle() for optionally-async AioThrottle
authorCasey Bodley <cbodley@redhat.com>
Mon, 28 Jan 2019 18:11:17 +0000 (13:11 -0500)
committerCasey Bodley <cbodley@redhat.com>
Wed, 24 Apr 2019 13:44:14 +0000 (09:44 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_aio_throttle.h

index 613abb534b00dd48a56e792d2966c5cfcabcee78..19baae6cbb2900aeaa974851cd8a3bba2495bdd1 100644 (file)
@@ -19,6 +19,7 @@
 #include <memory>
 #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> aio;
+  if (y) {
+    aio = std::make_unique<YieldingAioThrottle>(window_size,
+                                                y.get_io_context(),
+                                                y.get_yield_context());
+  } else {
+    aio = std::make_unique<BlockingAioThrottle>(window_size);
+  }
+  return aio;
+#else
+  return std::make_optional<BlockingAioThrottle>(window_size);
+#endif
+}
+
 } // namespace rgw