You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kvrocks.apache.org by hu...@apache.org on 2022/06/26 14:41:51 UTC
[incubator-kvrocks] branch unstable updated: Use unique_ptr in src/server.h (#673)
This is an automated email from the ASF dual-hosted git repository.
hulk pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/incubator-kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new 83aaf05 Use unique_ptr in src/server.h (#673)
83aaf05 is described below
commit 83aaf058a48fe70dd15bf76376cdaf64323759cb
Author: Jian Zhang <zj...@gmail.com>
AuthorDate: Sun Jun 26 22:41:46 2022 +0800
Use unique_ptr in src/server.h (#673)
Co-authored-by: tison <wa...@gmail.com>
Co-authored-by: Twice <tw...@gmail.com>
---
cppcheck.sh | 2 +-
src/server.cc | 6 +++---
src/server.h | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/cppcheck.sh b/cppcheck.sh
index 752ec78..e48bc57 100755
--- a/cppcheck.sh
+++ b/cppcheck.sh
@@ -27,4 +27,4 @@ set -ex
cppcheck --version
cppcheck \
--force --enable=${CHECK_TYPES} -U__GNUC__ -x ${LANG} src --std=${STANDARD} --error-exitcode=${ERROR_EXITCODE} \
- --inline-suppr --suppress=noCopyConstructor:src/server.cc --suppress=noOperatorEq:src/server.cc -j$(nproc)
+ --inline-suppr -j$(nproc)
diff --git a/src/server.cc b/src/server.cc
index f372046..512a7f6 100644
--- a/src/server.cc
+++ b/src/server.cc
@@ -51,7 +51,7 @@ Server::Server(Engine::Storage *storage, Config *config) :
}
// Init cluster
- cluster_ = new Cluster(this, config_->binds, config_->port);
+ cluster_ = std::unique_ptr<Cluster>(new Cluster(this, config_->binds, config_->port));
for (int i = 0; i < config->workers; i++) {
auto worker = new Worker(this, config);
@@ -110,8 +110,8 @@ Status Server::Start() {
if (config_->cluster_enabled) {
// Create objects used for slot migration
- slot_migrate_ = new SlotMigrate(this, config_->migrate_speed,
- config_->pipeline_size, config_->sequence_gap);
+ slot_migrate_ = std::unique_ptr<SlotMigrate>(new SlotMigrate(this, config_->migrate_speed,
+ config_->pipeline_size, config_->sequence_gap));
slot_import_ = new SlotImport(this);
// Create migrating thread
auto s = slot_migrate_->CreateMigrateHandleThread();
diff --git a/src/server.h b/src/server.h
index 2234890..e23877d 100644
--- a/src/server.h
+++ b/src/server.h
@@ -198,9 +198,9 @@ class Server {
Stats stats_;
Engine::Storage *storage_;
- Cluster *cluster_;
+ std::unique_ptr<Cluster> cluster_;
static std::atomic<int> unix_time_;
- class SlotMigrate *slot_migrate_ = nullptr;
+ std::unique_ptr<class SlotMigrate> slot_migrate_;
class SlotImport *slot_import_ = nullptr;
private: