From 99100fda3b6559eaa5d334f9ccd8983bba92078f Mon Sep 17 00:00:00 2001 From: lupengfan1 Date: Wed, 21 Aug 2024 17:16:46 +0800 Subject: [PATCH] fix(Bulkload) follow clang-tidy advice --- src/replica/bulk_load/replica_bulk_loader.cpp | 42 +++++++++---------- src/replica/bulk_load/replica_bulk_loader.h | 2 + 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/replica/bulk_load/replica_bulk_loader.cpp b/src/replica/bulk_load/replica_bulk_loader.cpp index bda9fa8a97..0028657b86 100644 --- a/src/replica/bulk_load/replica_bulk_loader.cpp +++ b/src/replica/bulk_load/replica_bulk_loader.cpp @@ -16,13 +16,15 @@ // under the License. #include +#include #include +#include #include +#include #include #include #include -#include #include "block_service/block_service_manager.h" #include "common/bulk_load_common.h" #include "common/gpid.h" @@ -474,12 +476,11 @@ error_code replica_bulk_loader::start_download(const std::string &remote_dir, // start download _is_downloading.store(true); - _download_task = - tasking::enqueue(LPC_BACKGROUND_BULK_LOAD, - tracker(), - [this, remote_dir, local_dir, download_file_metas, fs] { - download_sst_file(remote_dir, local_dir, download_file_metas, fs); - }); + _download_task = tasking::enqueue( + LPC_BACKGROUND_BULK_LOAD, + tracker(), + std::bind( + &replica_bulk_loader::download_files, this, provider_name, remote_dir, local_dir)); return ERR_OK; } @@ -528,15 +529,12 @@ void replica_bulk_loader::download_files(const std::string &provider_name, std::back_inserter(download_file_metas)); } if (!download_file_metas.empty()) { - _download_files_task[download_file_metas.back().name] = - tasking::enqueue(LPC_BACKGROUND_BULK_LOAD, - tracker(), - std::bind(&replica_bulk_loader::download_sst_file, - this, - remote_dir, - local_dir, - download_file_metas, - fs)); + _download_files_task[download_file_metas.back().name] = tasking::enqueue( + LPC_BACKGROUND_BULK_LOAD, + tracker(), + [this, remote_dir, local_dir, download_file_metas, fs]() mutable { + this->download_sst_file(remote_dir, local_dir, download_file_metas, fs); + }); } } @@ -610,12 +608,12 @@ void replica_bulk_loader::download_sst_file( // download next file if (!download_file_metas.empty()) { - _download_files_task[download_file_metas.back().name] = - tasking::enqueue(LPC_BACKGROUND_BULK_LOAD, - tracker(), - [this, remote_dir, local_dir, download_file_metas, fs] { - download_sst_file(remote_dir, local_dir, download_file_metas, fs); - }); + _download_files_task[download_file_metas.back().name] = tasking::enqueue( + LPC_BACKGROUND_BULK_LOAD, + tracker(), + [this, remote_dir, local_dir, download_file_metas, fs]() mutable { + this->download_sst_file(remote_dir, local_dir, download_file_metas, fs); + }); } } diff --git a/src/replica/bulk_load/replica_bulk_loader.h b/src/replica/bulk_load/replica_bulk_loader.h index 18daa45a19..99b1326758 100644 --- a/src/replica/bulk_load/replica_bulk_loader.h +++ b/src/replica/bulk_load/replica_bulk_loader.h @@ -22,6 +22,7 @@ #include #include #include +#include #include "bulk_load_types.h" #include "common/replication_other_types.h" @@ -36,6 +37,7 @@ namespace dsn { class task_tracker; + namespace dist { namespace block_service { class block_filesystem;