Prefer lambda expressions over std::bind

pull/17090/head
Yash Tibrewal 6 years ago
parent 7a08e3b679
commit e08a2b387a
  1. 7
      src/cpp/client/secure_credentials.cc
  2. 7
      src/cpp/server/secure_server_credentials.cc
  3. 10
      src/cpp/server/server_cc.cc

@ -228,9 +228,10 @@ int MetadataCredentialsPluginWrapper::GetMetadata(
} }
if (w->plugin_->IsBlocking()) { if (w->plugin_->IsBlocking()) {
// Asynchronous return. // Asynchronous return.
w->thread_pool_->Add( w->thread_pool_->Add([=]() {
std::bind(&MetadataCredentialsPluginWrapper::InvokePlugin, w, context, w->MetadataCredentialsPluginWrapper::InvokePlugin(
cb, user_data, nullptr, nullptr, nullptr, nullptr)); context, cb, user_data, nullptr, nullptr, nullptr, nullptr);
});
return 0; return 0;
} else { } else {
// Synchronous return. // Synchronous return.

@ -43,9 +43,10 @@ void AuthMetadataProcessorAyncWrapper::Process(
return; return;
} }
if (w->processor_->IsBlocking()) { if (w->processor_->IsBlocking()) {
w->thread_pool_->Add( w->thread_pool_->Add([=]() {
std::bind(&AuthMetadataProcessorAyncWrapper::InvokeProcessor, w, w->AuthMetadataProcessorAyncWrapper::InvokeProcessor(context, md, num_md,
context, md, num_md, cb, user_data)); cb, user_data);
});
} else { } else {
// invoke directly. // invoke directly.
w->InvokeProcessor(context, md, num_md, cb, user_data); w->InvokeProcessor(context, md, num_md, cb, user_data);

@ -268,8 +268,8 @@ class Server::SyncRequest final : public internal::CompletionQueueTag {
interceptor_methods_.SetRecvMessage(request_); interceptor_methods_.SetRecvMessage(request_);
} }
auto f = std::bind(&CallData::ContinueRunAfterInterception, this); if (interceptor_methods_.RunInterceptors(
if (interceptor_methods_.RunInterceptors(f)) { [this]() { ContinueRunAfterInterception(); })) {
ContinueRunAfterInterception(); ContinueRunAfterInterception();
} else { } else {
// There were interceptors to be run, so ContinueRunAfterInterception // There were interceptors to be run, so ContinueRunAfterInterception
@ -981,10 +981,8 @@ bool ServerInterface::BaseAsyncRequest::FinalizeResult(void** tag,
interceptor_methods_.AddInterceptionHookPoint( interceptor_methods_.AddInterceptionHookPoint(
experimental::InterceptionHookPoints::POST_RECV_INITIAL_METADATA); experimental::InterceptionHookPoints::POST_RECV_INITIAL_METADATA);
interceptor_methods_.SetRecvInitialMetadata(&context_->client_metadata_); interceptor_methods_.SetRecvInitialMetadata(&context_->client_metadata_);
auto f = std::bind(&ServerInterface::BaseAsyncRequest:: if (interceptor_methods_.RunInterceptors(
ContinueFinalizeResultAfterInterception, [this]() { ContinueFinalizeResultAfterInterception(); })) {
this);
if (interceptor_methods_.RunInterceptors(f)) {
// There are no interceptors to run. Continue // There are no interceptors to run. Continue
} else { } else {
// There were interceptors to be run, so // There were interceptors to be run, so

Loading…
Cancel
Save