Skip to content

Commit

Permalink
clean clang-tidy error from FlashService (#4170)
Browse files Browse the repository at this point in the history
ref #2843
  • Loading branch information
bestwoody authored Mar 2, 2022
1 parent 6611d54 commit fa48fa2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
17 changes: 9 additions & 8 deletions dbms/src/Flash/FlashService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ FlashService::FlashService(IServer & server_)
batch_cop_pool = std::make_unique<ThreadPool>(batch_cop_pool_size, [] { setThreadName("batch-cop-pool"); });
}

// Use executeInThreadPool to submit job to thread pool which return grpc::Status.
grpc::Status executeInThreadPool(const std::unique_ptr<ThreadPool> & pool, std::function<grpc::Status()> job)
{
std::packaged_task<grpc::Status()> task(job);
std::future<grpc::Status> future = task.get_future();
pool->schedule([&task] { task(); });
return future.get();
}

grpc::Status FlashService::Coprocessor(
grpc::ServerContext * grpc_context,
const coprocessor::Request * request,
Expand Down Expand Up @@ -337,14 +346,6 @@ String getClientMetaVarWithDefault(const grpc::ServerContext * grpc_context, con
return default_val;
}

grpc::Status FlashService::executeInThreadPool(const std::unique_ptr<ThreadPool> & pool, std::function<grpc::Status()> job)
{
std::packaged_task<grpc::Status()> task(job);
std::future<grpc::Status> future = task.get_future();
pool->schedule([&task] { task(); });
return future.get();
}

std::tuple<ContextPtr, grpc::Status> FlashService::createDBContext(const grpc::ServerContext * grpc_context) const
{
try
Expand Down
4 changes: 0 additions & 4 deletions dbms/src/Flash/FlashService.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ class FlashService final : public tikvpb::Tikv::Service
private:
std::tuple<ContextPtr, ::grpc::Status> createDBContext(const grpc::ServerContext * grpc_context) const;

// Use executeInThreadPool to submit job to thread pool which return grpc::Status.
grpc::Status executeInThreadPool(const std::unique_ptr<ThreadPool> & pool, std::function<grpc::Status()>);

private:
IServer & server;
const TiFlashSecurityConfig & security_config;
Poco::Logger * log;
Expand Down

0 comments on commit fa48fa2

Please sign in to comment.