]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librados: add move operations to IoCtx
authorCasey Bodley <cbodley@redhat.com>
Tue, 23 Oct 2018 21:26:11 +0000 (17:26 -0400)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 8 Nov 2018 17:19:30 +0000 (09:19 -0800)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/include/rados/librados.hpp
src/librados/librados_cxx.cc

index 0f47dd6b7fda317e1b8eb726b331ced4f2ffee1a..9951d9ebbcba2e6f571b4d033d5b84f6c8386ebb 100644 (file)
@@ -710,6 +710,8 @@ namespace librados
     static void from_rados_ioctx_t(rados_ioctx_t p, IoCtx &pool);
     IoCtx(const IoCtx& rhs);
     IoCtx& operator=(const IoCtx& rhs);
+    IoCtx(IoCtx&& rhs) noexcept;
+    IoCtx& operator=(IoCtx&& rhs) noexcept;
 
     ~IoCtx();
 
index c1d2f3fd10ccaa5f9d28aa2ecb5ef67a0d151d77..9768eaa9d4e80c49e9d952b06525d92d39c7223d 100644 (file)
@@ -1051,6 +1051,19 @@ librados::IoCtx& librados::IoCtx::operator=(const IoCtx& rhs)
   return *this;
 }
 
+librados::IoCtx::IoCtx(IoCtx&& rhs) noexcept
+  : io_ctx_impl(std::exchange(rhs.io_ctx_impl, nullptr))
+{
+}
+
+librados::IoCtx& librados::IoCtx::operator=(IoCtx&& rhs) noexcept
+{
+  if (io_ctx_impl)
+    io_ctx_impl->put();
+  io_ctx_impl = std::exchange(rhs.io_ctx_impl, nullptr);
+  return *this;
+}
+
 librados::IoCtx::~IoCtx()
 {
   close();