]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librados_test_stub: implement move operations
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 8 Nov 2018 20:43:21 +0000 (12:43 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 8 Nov 2018 20:43:21 +0000 (12:43 -0800)
Need to match whatever librados implements.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/test/librados_test_stub/LibradosTestStub.cc

index 17221b24c30aa6ab0e94fbebef66e1f0c8b95cd8..4ad154bd1dcc5575b62127ca1143c8787805800b 100644 (file)
@@ -367,6 +367,10 @@ IoCtx::IoCtx(const IoCtx& rhs) {
   }
 }
 
+IoCtx::IoCtx(IoCtx&& rhs) noexcept : io_ctx_impl(std::exchange(rhs.io_ctx_impl, nullptr))
+{
+}
+
 IoCtx& IoCtx::operator=(const IoCtx& rhs) {
   if (io_ctx_impl) {
     TestIoCtxImpl *ctx = reinterpret_cast<TestIoCtxImpl*>(io_ctx_impl);
@@ -381,6 +385,17 @@ IoCtx& IoCtx::operator=(const IoCtx& rhs) {
   return *this;
 }
 
+librados::IoCtx& librados::IoCtx::operator=(IoCtx&& rhs) noexcept
+{
+  if (io_ctx_impl) {
+    TestIoCtxImpl *ctx = reinterpret_cast<TestIoCtxImpl*>(io_ctx_impl);
+    ctx->put();
+  }
+
+  io_ctx_impl = std::exchange(rhs.io_ctx_impl, nullptr);
+  return *this;
+}
+
 int IoCtx::aio_flush() {
   TestIoCtxImpl *ctx = reinterpret_cast<TestIoCtxImpl*>(io_ctx_impl);
   ctx->aio_flush();