From 4b67b6394209cb5d095696ef42f112bde59384fe Mon Sep 17 00:00:00 2001 From: panda-sheep <59197347+panda-sheep@users.noreply.github.com> Date: Thu, 25 Mar 2021 07:27:05 +0800 Subject: [PATCH] address critical27's comment --- src/storage/CommonUtils.h | 14 ++++++++++++++ src/storage/mutate/AddEdgesProcessor.cpp | 4 ++-- src/storage/mutate/AddVerticesProcessor.cpp | 4 ++-- src/storage/mutate/DeleteEdgesProcessor.cpp | 4 ++-- src/storage/mutate/DeleteVerticesProcessor.cpp | 4 ++-- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/storage/CommonUtils.h b/src/storage/CommonUtils.h index 93245101d..988f1ca83 100644 --- a/src/storage/CommonUtils.h +++ b/src/storage/CommonUtils.h @@ -109,6 +109,20 @@ class IndexCountWrapper { count_->fetch_add(1, std::memory_order_release); } + IndexCountWrapper(const IndexCountWrapper&) = delete; + + IndexCountWrapper(IndexCountWrapper&& icw) noexcept + : count_(icw.count_) {} + + IndexCountWrapper& operator=(const IndexCountWrapper&) = delete; + + IndexCountWrapper& operator=(IndexCountWrapper&& icw) noexcept { + if (this != &icw) { + count_ = icw.count_; + } + return *this; + } + ~IndexCountWrapper() { count_->fetch_sub(1, std::memory_order_release); } diff --git a/src/storage/mutate/AddEdgesProcessor.cpp b/src/storage/mutate/AddEdgesProcessor.cpp index 4ef58eb5a..89e6bcc7b 100644 --- a/src/storage/mutate/AddEdgesProcessor.cpp +++ b/src/storage/mutate/AddEdgesProcessor.cpp @@ -268,9 +268,9 @@ void AddEdgesProcessor::doProcessWithIndex(const cpp2::AddEdgesRequest& req) { continue; } env_->kvstore_->asyncAppendBatch(spaceId_, partId, std::move(batch), - [l = std::move(lg), &wrapper, partId, this](kvstore::ResultCode kvRet) { + [l = std::move(lg), icw = std::move(wrapper), partId, this](kvstore::ResultCode kvRet) { UNUSED(l); - UNUSED(wrapper); + UNUSED(icw); handleAsync(spaceId_, partId, kvRet); }); } diff --git a/src/storage/mutate/AddVerticesProcessor.cpp b/src/storage/mutate/AddVerticesProcessor.cpp index 48ea95c95..94a05747a 100644 --- a/src/storage/mutate/AddVerticesProcessor.cpp +++ b/src/storage/mutate/AddVerticesProcessor.cpp @@ -279,9 +279,9 @@ void AddVerticesProcessor::doProcessWithIndex(const cpp2::AddVerticesRequest& re continue; } env_->kvstore_->asyncAppendBatch(spaceId_, partId, std::move(batch), - [l = std::move(lg), &wrapper, partId, this](kvstore::ResultCode kvRet) { + [l = std::move(lg), icw = std::move(wrapper), partId, this](kvstore::ResultCode kvRet) { UNUSED(l); - UNUSED(wrapper); + UNUSED(icw); handleAsync(spaceId_, partId, kvRet); }); } diff --git a/src/storage/mutate/DeleteEdgesProcessor.cpp b/src/storage/mutate/DeleteEdgesProcessor.cpp index d3ebfc43a..460524f71 100644 --- a/src/storage/mutate/DeleteEdgesProcessor.cpp +++ b/src/storage/mutate/DeleteEdgesProcessor.cpp @@ -111,9 +111,9 @@ void DeleteEdgesProcessor::process(const cpp2::DeleteEdgesRequest& req) { continue; } env_->kvstore_->asyncAppendBatch(spaceId_, partId, std::move(nebula::value(batch)), - [l = std::move(lg), &wrapper, partId, this](kvstore::ResultCode code) { + [l = std::move(lg), icw = std::move(wrapper), partId, this](kvstore::ResultCode code) { UNUSED(l); - UNUSED(wrapper); + UNUSED(icw); handleAsync(spaceId_, partId, code); }); } diff --git a/src/storage/mutate/DeleteVerticesProcessor.cpp b/src/storage/mutate/DeleteVerticesProcessor.cpp index f772c8730..5b5637a5a 100644 --- a/src/storage/mutate/DeleteVerticesProcessor.cpp +++ b/src/storage/mutate/DeleteVerticesProcessor.cpp @@ -113,9 +113,9 @@ void DeleteVerticesProcessor::process(const cpp2::DeleteVerticesRequest& req) { continue; } env_->kvstore_->asyncAppendBatch(spaceId_, partId, std::move(nebula::value(batch)), - [l = std::move(lg), &wrapper, partId, this](kvstore::ResultCode code) { + [l = std::move(lg), icw = std::move(wrapper), partId, this](kvstore::ResultCode code) { UNUSED(l); - UNUSED(wrapper); + UNUSED(icw); handleAsync(spaceId_, partId, code); }); }