resolve_address_impl.h
Go to the documentation of this file.
1 //
2 // Copyright 2015 gRPC authors.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #ifndef GRPC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_IMPL_H
18 #define GRPC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_IMPL_H
19 
21 
22 #include <stddef.h>
23 
26 
27 namespace grpc_core {
28 
29 // A fire and forget class to schedule DNS resolution callbacks on the ExecCtx,
30 // which is frequently necessary to avoid lock inversion related problems.
32  public:
34  std::function<void(absl::StatusOr<std::vector<grpc_resolved_address>>)>
35  on_done,
36  absl::StatusOr<std::vector<grpc_resolved_address>> param)
37  : on_done_(std::move(on_done)), param_(std::move(param)) {
38  GRPC_CLOSURE_INIT(&closure_, RunCallback, this, grpc_schedule_on_exec_ctx);
40  }
41 
42  private:
43  static void RunCallback(void* arg, grpc_error_handle /* error */) {
45  static_cast<DNSCallbackExecCtxScheduler*>(arg);
46  self->on_done_(std::move(self->param_));
47  delete self;
48  }
49 
50  const std::function<void(absl::StatusOr<std::vector<grpc_resolved_address>>)>
54 };
55 
56 } // namespace grpc_core
57 
58 #endif /* GRPC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_IMPL_H */
GRPC_CLOSURE_INIT
#define GRPC_CLOSURE_INIT(closure, cb, cb_arg, scheduler)
Definition: closure.h:115
grpc_core::DNSCallbackExecCtxScheduler::RunCallback
static void RunCallback(void *arg, grpc_error_handle)
Definition: resolve_address_impl.h:43
GRPC_ERROR_NONE
#define GRPC_ERROR_NONE
Definition: error.h:234
grpc_core::DNSCallbackExecCtxScheduler
Definition: resolve_address_impl.h:31
grpc_core
Definition: call_metric_recorder.h:31
resolve_address.h
grpc_core::DNSCallbackExecCtxScheduler::DNSCallbackExecCtxScheduler
DNSCallbackExecCtxScheduler(std::function< void(absl::StatusOr< std::vector< grpc_resolved_address >>)> on_done, absl::StatusOr< std::vector< grpc_resolved_address >> param)
Definition: resolve_address_impl.h:33
grpc_core::DNSCallbackExecCtxScheduler::on_done_
const std::function< void(absl::StatusOr< std::vector< grpc_resolved_address >>)> on_done_
Definition: resolve_address_impl.h:51
DEBUG_LOCATION
#define DEBUG_LOCATION
Definition: debug_location.h:41
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
grpc_core::DNSCallbackExecCtxScheduler::param_
absl::StatusOr< std::vector< grpc_resolved_address > > param_
Definition: resolve_address_impl.h:52
arg
Definition: cmdline.cc:40
grpc_core::DNSCallbackExecCtxScheduler::closure_
grpc_closure closure_
Definition: resolve_address_impl.h:53
port.h
std
Definition: grpcpp/impl/codegen/async_unary_call.h:407
arg
struct arg arg
grpc_core::ExecCtx::Run
static void Run(const DebugLocation &location, grpc_closure *closure, grpc_error_handle error)
Definition: exec_ctx.cc:98
absl::StatusOr
Definition: abseil-cpp/absl/status/statusor.h:187
grpc_error
Definition: error_internal.h:42
function
std::function< bool(GrpcTool *, int, const char **, const CliCredentials &, GrpcToolOutputCallback)> function
Definition: grpc_tool.cc:250
self
PHP_PROTO_OBJECT_FREE_END PHP_PROTO_OBJECT_DTOR_END intern self
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/map.c:543
grpc_closure
Definition: closure.h:56
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:10