aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/ext/filters/client_channel/lb_policy.cc
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2017-10-13 16:07:13 -0700
committerGravatar Yash Tibrewal <yashkt@google.com>2017-10-18 17:12:19 -0700
commit0ee7574732a06e8cace4e099a678f4bd5dbff679 (patch)
treee43d5de442fdcc3d39cd5af687f319fa39612d3f /src/core/ext/filters/client_channel/lb_policy.cc
parent6bf5f833efe2cb9e2ecc14358dd9699cd5d05263 (diff)
Removing instances of exec_ctx being passed around in functions in
src/core. exec_ctx is now a thread_local pointer of type ExecCtx instead of grpc_exec_ctx which is initialized whenever ExecCtx is instantiated. ExecCtx also keeps track of the previous exec_ctx so that nesting of exec_ctx is allowed. This means that there is only one exec_ctx being used at any time. Also, grpc_exec_ctx_finish is called in the destructor of the object, and the previous exec_ctx is restored to avoid breaking current functionality. The code still explicitly calls grpc_exec_ctx_finish because removing all such instances causes the code to break.
Diffstat (limited to 'src/core/ext/filters/client_channel/lb_policy.cc')
-rw-r--r--src/core/ext/filters/client_channel/lb_policy.cc75
1 files changed, 31 insertions, 44 deletions
diff --git a/src/core/ext/filters/client_channel/lb_policy.cc b/src/core/ext/filters/client_channel/lb_policy.cc
index 8e6673d737..be3c2176bf 100644
--- a/src/core/ext/filters/client_channel/lb_policy.cc
+++ b/src/core/ext/filters/client_channel/lb_policy.cc
@@ -65,28 +65,25 @@ void grpc_lb_policy_ref(grpc_lb_policy *policy REF_FUNC_EXTRA_ARGS) {
ref_mutate(policy, 1 << WEAK_REF_BITS, 0 REF_MUTATE_PASS_ARGS("STRONG_REF"));
}
-static void shutdown_locked(grpc_exec_ctx *exec_ctx, void *arg,
- grpc_error *error) {
+static void shutdown_locked(void *arg, grpc_error *error) {
grpc_lb_policy *policy = (grpc_lb_policy *)arg;
- policy->vtable->shutdown_locked(exec_ctx, policy);
- GRPC_LB_POLICY_WEAK_UNREF(exec_ctx, policy, "strong-unref");
+ policy->vtable->shutdown_locked(policy);
+ GRPC_LB_POLICY_WEAK_UNREF(policy, "strong-unref");
}
-void grpc_lb_policy_unref(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy *policy REF_FUNC_EXTRA_ARGS) {
+void grpc_lb_policy_unref(grpc_lb_policy *policy REF_FUNC_EXTRA_ARGS) {
gpr_atm old_val =
ref_mutate(policy, (gpr_atm)1 - (gpr_atm)(1 << WEAK_REF_BITS),
1 REF_MUTATE_PASS_ARGS("STRONG_UNREF"));
gpr_atm mask = ~(gpr_atm)((1 << WEAK_REF_BITS) - 1);
gpr_atm check = 1 << WEAK_REF_BITS;
if ((old_val & mask) == check) {
- GRPC_CLOSURE_SCHED(exec_ctx, GRPC_CLOSURE_CREATE(
- shutdown_locked, policy,
- grpc_combiner_scheduler(policy->combiner)),
- GRPC_ERROR_NONE);
+ GRPC_CLOSURE_SCHED(
+ GRPC_CLOSURE_CREATE(shutdown_locked, policy,
+ grpc_combiner_scheduler(policy->combiner)),
+ GRPC_ERROR_NONE);
} else {
- grpc_lb_policy_weak_unref(exec_ctx,
- policy REF_FUNC_PASS_ARGS("strong-unref"));
+ grpc_lb_policy_weak_unref(policy REF_FUNC_PASS_ARGS("strong-unref"));
}
}
@@ -94,71 +91,61 @@ void grpc_lb_policy_weak_ref(grpc_lb_policy *policy REF_FUNC_EXTRA_ARGS) {
ref_mutate(policy, 1, 0 REF_MUTATE_PASS_ARGS("WEAK_REF"));
}
-void grpc_lb_policy_weak_unref(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy *policy REF_FUNC_EXTRA_ARGS) {
+void grpc_lb_policy_weak_unref(grpc_lb_policy *policy REF_FUNC_EXTRA_ARGS) {
gpr_atm old_val =
ref_mutate(policy, -(gpr_atm)1, 1 REF_MUTATE_PASS_ARGS("WEAK_UNREF"));
if (old_val == 1) {
- grpc_pollset_set_destroy(exec_ctx, policy->interested_parties);
+ grpc_pollset_set_destroy(policy->interested_parties);
grpc_combiner *combiner = policy->combiner;
- policy->vtable->destroy(exec_ctx, policy);
- GRPC_COMBINER_UNREF(exec_ctx, combiner, "lb_policy");
+ policy->vtable->destroy(policy);
+ GRPC_COMBINER_UNREF(combiner, "lb_policy");
}
}
-int grpc_lb_policy_pick_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
+int grpc_lb_policy_pick_locked(grpc_lb_policy *policy,
const grpc_lb_policy_pick_args *pick_args,
grpc_connected_subchannel **target,
grpc_call_context_element *context,
void **user_data, grpc_closure *on_complete) {
- return policy->vtable->pick_locked(exec_ctx, policy, pick_args, target,
- context, user_data, on_complete);
+ return policy->vtable->pick_locked(policy, pick_args, target, context,
+ user_data, on_complete);
}
-void grpc_lb_policy_cancel_pick_locked(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy *policy,
+void grpc_lb_policy_cancel_pick_locked(grpc_lb_policy *policy,
grpc_connected_subchannel **target,
grpc_error *error) {
- policy->vtable->cancel_pick_locked(exec_ctx, policy, target, error);
+ policy->vtable->cancel_pick_locked(policy, target, error);
}
-void grpc_lb_policy_cancel_picks_locked(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy *policy,
+void grpc_lb_policy_cancel_picks_locked(grpc_lb_policy *policy,
uint32_t initial_metadata_flags_mask,
uint32_t initial_metadata_flags_eq,
grpc_error *error) {
- policy->vtable->cancel_picks_locked(exec_ctx, policy,
- initial_metadata_flags_mask,
+ policy->vtable->cancel_picks_locked(policy, initial_metadata_flags_mask,
initial_metadata_flags_eq, error);
}
-void grpc_lb_policy_exit_idle_locked(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy *policy) {
- policy->vtable->exit_idle_locked(exec_ctx, policy);
+void grpc_lb_policy_exit_idle_locked(grpc_lb_policy *policy) {
+ policy->vtable->exit_idle_locked(policy);
}
-void grpc_lb_policy_ping_one_locked(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy *policy,
+void grpc_lb_policy_ping_one_locked(grpc_lb_policy *policy,
grpc_closure *closure) {
- policy->vtable->ping_one_locked(exec_ctx, policy, closure);
+ policy->vtable->ping_one_locked(policy, closure);
}
void grpc_lb_policy_notify_on_state_change_locked(
- grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
- grpc_connectivity_state *state, grpc_closure *closure) {
- policy->vtable->notify_on_state_change_locked(exec_ctx, policy, state,
- closure);
+ grpc_lb_policy *policy, grpc_connectivity_state *state,
+ grpc_closure *closure) {
+ policy->vtable->notify_on_state_change_locked(policy, state, closure);
}
grpc_connectivity_state grpc_lb_policy_check_connectivity_locked(
- grpc_exec_ctx *exec_ctx, grpc_lb_policy *policy,
- grpc_error **connectivity_error) {
- return policy->vtable->check_connectivity_locked(exec_ctx, policy,
- connectivity_error);
+ grpc_lb_policy *policy, grpc_error **connectivity_error) {
+ return policy->vtable->check_connectivity_locked(policy, connectivity_error);
}
-void grpc_lb_policy_update_locked(grpc_exec_ctx *exec_ctx,
- grpc_lb_policy *policy,
+void grpc_lb_policy_update_locked(grpc_lb_policy *policy,
const grpc_lb_policy_args *lb_policy_args) {
- policy->vtable->update_locked(exec_ctx, policy, lb_policy_args);
+ policy->vtable->update_locked(policy, lb_policy_args);
}