Пример #1
0
void grpc_resource_user_free(grpc_exec_ctx *exec_ctx,
                             grpc_resource_user *resource_user, size_t size) {
  gpr_mu_lock(&resource_user->mu);
  bool was_zero_or_negative = resource_user->free_pool <= 0;
  resource_user->free_pool += (int64_t)size;
  if (grpc_resource_quota_trace) {
    gpr_log(GPR_DEBUG, "RQ %s %s: free %" PRIdPTR "; free_pool -> %" PRId64,
            resource_user->resource_quota->name, resource_user->name, size,
            resource_user->free_pool);
  }
  bool is_bigger_than_zero = resource_user->free_pool > 0;
  if (is_bigger_than_zero && was_zero_or_negative &&
      !resource_user->added_to_free_pool) {
    resource_user->added_to_free_pool = true;
    grpc_closure_sched(exec_ctx, &resource_user->add_to_free_pool_closure,
                       GRPC_ERROR_NONE);
  }
  gpr_mu_unlock(&resource_user->mu);
  ru_unref_by(exec_ctx, resource_user, (gpr_atm)size);
}
Пример #2
0
void grpc_resource_user_unref(grpc_exec_ctx *exec_ctx,
                              grpc_resource_user *resource_user) {
  ru_unref_by(exec_ctx, resource_user, 1);
}