Move avl to its own directory and rename it to grpc_avl

pull/14184/head
Vijay Pai 7 years ago
parent 9494a9dacf
commit 8f4fbb1c55
  1. 4
      BUILD
  2. 60
      CMakeLists.txt
  3. 79
      Makefile
  4. 23
      build.yaml
  5. 3
      config.m4
  6. 3
      config.w32
  7. 4
      gRPC-C++.podspec
  8. 6
      gRPC-Core.podspec
  9. 4
      grpc.gemspec
  10. 5
      grpc.gyp
  11. 4
      package.xml
  12. 16
      src/core/ext/filters/client_channel/retry_throttle.cc
  13. 46
      src/core/ext/filters/client_channel/subchannel_index.cc
  14. 100
      src/core/lib/avl/avl.cc
  15. 48
      src/core/lib/avl/avl.h
  16. 2
      src/python/grpcio/grpc_core_dependencies.py
  17. 30
      test/core/avl/BUILD
  18. 3659
      test/core/avl/avl_test.cc
  19. 10
      test/core/gpr/BUILD
  20. 3659
      test/core/gpr/avl_test.cc
  21. 2
      tools/doxygen/Doxyfile.c++.internal
  22. 4
      tools/doxygen/Doxyfile.core.internal
  23. 37
      tools/run_tests/generated/sources_and_headers.json
  24. 48
      tools/run_tests/generated/tests.json

@ -456,7 +456,6 @@ grpc_cc_library(
"src/core/lib/gpr/alloc.cc",
"src/core/lib/gpr/arena.cc",
"src/core/lib/gpr/atm.cc",
"src/core/lib/gpr/avl.cc",
"src/core/lib/gpr/cmdline.cc",
"src/core/lib/gpr/cpu_iphone.cc",
"src/core/lib/gpr/cpu_linux.cc",
@ -499,7 +498,6 @@ grpc_cc_library(
hdrs = [
"src/core/lib/profiling/timers.h",
"src/core/lib/gpr/arena.h",
"src/core/lib/gpr/avl.h",
"src/core/lib/gpr/env.h",
"src/core/lib/gpr/fork.h",
"src/core/lib/gpr/useful.h",
@ -627,6 +625,7 @@ grpc_cc_library(
grpc_cc_library(
name = "grpc_base_c",
srcs = [
"src/core/lib/avl/avl.cc",
"src/core/lib/backoff/backoff.cc",
"src/core/lib/channel/channel_args.cc",
"src/core/lib/channel/channel_stack.cc",
@ -762,6 +761,7 @@ grpc_cc_library(
"src/core/lib/transport/transport_op_string.cc",
],
hdrs = [
"src/core/lib/avl/avl.h",
"src/core/lib/backoff/backoff.h",
"src/core/lib/channel/channel_args.h",
"src/core/lib/channel/channel_stack.h",

@ -213,6 +213,7 @@ add_dependencies(buildtests_c algorithm_test)
add_dependencies(buildtests_c alloc_test)
add_dependencies(buildtests_c alpn_test)
add_dependencies(buildtests_c arena_test)
add_dependencies(buildtests_c avl_test)
add_dependencies(buildtests_c bad_server_response_test)
add_dependencies(buildtests_c bin_decoder_test)
add_dependencies(buildtests_c bin_encoder_test)
@ -257,7 +258,6 @@ endif()
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_c goaway_server_test)
endif()
add_dependencies(buildtests_c gpr_avl_test)
add_dependencies(buildtests_c gpr_cmdline_test)
add_dependencies(buildtests_c gpr_cpu_test)
add_dependencies(buildtests_c gpr_env_test)
@ -628,7 +628,6 @@ add_library(gpr
src/core/lib/gpr/alloc.cc
src/core/lib/gpr/arena.cc
src/core/lib/gpr/atm.cc
src/core/lib/gpr/avl.cc
src/core/lib/gpr/cmdline.cc
src/core/lib/gpr/cpu_iphone.cc
src/core/lib/gpr/cpu_linux.cc
@ -792,6 +791,7 @@ endif (gRPC_BUILD_TESTS)
add_library(grpc
src/core/lib/surface/init.cc
src/core/lib/avl/avl.cc
src/core/lib/backoff/backoff.cc
src/core/lib/channel/channel_args.cc
src/core/lib/channel/channel_stack.cc
@ -1134,6 +1134,7 @@ endif()
add_library(grpc_cronet
src/core/lib/surface/init.cc
src/core/lib/avl/avl.cc
src/core/lib/backoff/backoff.cc
src/core/lib/channel/channel_args.cc
src/core/lib/channel/channel_stack.cc
@ -1458,6 +1459,7 @@ add_library(grpc_test_util
test/core/util/slice_splitter.cc
test/core/util/tracer_util.cc
test/core/util/trickle_endpoint.cc
src/core/lib/avl/avl.cc
src/core/lib/backoff/backoff.cc
src/core/lib/channel/channel_args.cc
src/core/lib/channel/channel_stack.cc
@ -1726,6 +1728,7 @@ add_library(grpc_test_util_unsecure
test/core/util/slice_splitter.cc
test/core/util/tracer_util.cc
test/core/util/trickle_endpoint.cc
src/core/lib/avl/avl.cc
src/core/lib/backoff/backoff.cc
src/core/lib/channel/channel_args.cc
src/core/lib/channel/channel_stack.cc
@ -1977,6 +1980,7 @@ endif (gRPC_BUILD_TESTS)
add_library(grpc_unsecure
src/core/lib/surface/init.cc
src/core/lib/surface/init_unsecure.cc
src/core/lib/avl/avl.cc
src/core/lib/backoff/backoff.cc
src/core/lib/channel/channel_args.cc
src/core/lib/channel/channel_stack.cc
@ -2709,6 +2713,7 @@ add_library(grpc++_cronet
src/core/ext/transport/chttp2/transport/stream_map.cc
src/core/ext/transport/chttp2/transport/varint.cc
src/core/ext/transport/chttp2/transport/writing.cc
src/core/lib/avl/avl.cc
src/core/lib/backoff/backoff.cc
src/core/lib/channel/channel_args.cc
src/core/lib/channel/channel_stack.cc
@ -4832,6 +4837,32 @@ target_link_libraries(arena_test
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(avl_test
test/core/avl/avl_test.cc
)
target_include_directories(avl_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
)
target_link_libraries(avl_test
${_gRPC_ALLTARGETS_LIBRARIES}
gpr_test_util
gpr
grpc
)
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(bad_server_response_test
test/core/end2end/bad_server_response_test.cc
)
@ -5633,31 +5664,6 @@ endif()
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(gpr_avl_test
test/core/gpr/avl_test.cc
)
target_include_directories(gpr_avl_test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE ${_gRPC_SSL_INCLUDE_DIR}
PRIVATE ${_gRPC_PROTOBUF_INCLUDE_DIR}
PRIVATE ${_gRPC_ZLIB_INCLUDE_DIR}
PRIVATE ${_gRPC_BENCHMARK_INCLUDE_DIR}
PRIVATE ${_gRPC_CARES_INCLUDE_DIR}
PRIVATE ${_gRPC_GFLAGS_INCLUDE_DIR}
)
target_link_libraries(gpr_avl_test
${_gRPC_ALLTARGETS_LIBRARIES}
gpr_test_util
gpr
)
endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
add_executable(gpr_cmdline_test
test/core/gpr/cmdline_test.cc
)

@ -955,6 +955,7 @@ alloc_test: $(BINDIR)/$(CONFIG)/alloc_test
alpn_test: $(BINDIR)/$(CONFIG)/alpn_test
api_fuzzer: $(BINDIR)/$(CONFIG)/api_fuzzer
arena_test: $(BINDIR)/$(CONFIG)/arena_test
avl_test: $(BINDIR)/$(CONFIG)/avl_test
bad_server_response_test: $(BINDIR)/$(CONFIG)/bad_server_response_test
bin_decoder_test: $(BINDIR)/$(CONFIG)/bin_decoder_test
bin_encoder_test: $(BINDIR)/$(CONFIG)/bin_encoder_test
@ -985,7 +986,6 @@ fling_server: $(BINDIR)/$(CONFIG)/fling_server
fling_stream_test: $(BINDIR)/$(CONFIG)/fling_stream_test
fling_test: $(BINDIR)/$(CONFIG)/fling_test
goaway_server_test: $(BINDIR)/$(CONFIG)/goaway_server_test
gpr_avl_test: $(BINDIR)/$(CONFIG)/gpr_avl_test
gpr_cmdline_test: $(BINDIR)/$(CONFIG)/gpr_cmdline_test
gpr_cpu_test: $(BINDIR)/$(CONFIG)/gpr_cpu_test
gpr_env_test: $(BINDIR)/$(CONFIG)/gpr_env_test
@ -1372,6 +1372,7 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/alloc_test \
$(BINDIR)/$(CONFIG)/alpn_test \
$(BINDIR)/$(CONFIG)/arena_test \
$(BINDIR)/$(CONFIG)/avl_test \
$(BINDIR)/$(CONFIG)/bad_server_response_test \
$(BINDIR)/$(CONFIG)/bin_decoder_test \
$(BINDIR)/$(CONFIG)/bin_encoder_test \
@ -1400,7 +1401,6 @@ buildtests_c: privatelibs_c \
$(BINDIR)/$(CONFIG)/fling_stream_test \
$(BINDIR)/$(CONFIG)/fling_test \
$(BINDIR)/$(CONFIG)/goaway_server_test \
$(BINDIR)/$(CONFIG)/gpr_avl_test \
$(BINDIR)/$(CONFIG)/gpr_cmdline_test \
$(BINDIR)/$(CONFIG)/gpr_cpu_test \
$(BINDIR)/$(CONFIG)/gpr_env_test \
@ -1812,6 +1812,8 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/alpn_test || ( echo test alpn_test failed ; exit 1 )
$(E) "[RUN] Testing arena_test"
$(Q) $(BINDIR)/$(CONFIG)/arena_test || ( echo test arena_test failed ; exit 1 )
$(E) "[RUN] Testing avl_test"
$(Q) $(BINDIR)/$(CONFIG)/avl_test || ( echo test avl_test failed ; exit 1 )
$(E) "[RUN] Testing bad_server_response_test"
$(Q) $(BINDIR)/$(CONFIG)/bad_server_response_test || ( echo test bad_server_response_test failed ; exit 1 )
$(E) "[RUN] Testing bin_decoder_test"
@ -1864,8 +1866,6 @@ test_c: buildtests_c
$(Q) $(BINDIR)/$(CONFIG)/fling_test || ( echo test fling_test failed ; exit 1 )
$(E) "[RUN] Testing goaway_server_test"
$(Q) $(BINDIR)/$(CONFIG)/goaway_server_test || ( echo test goaway_server_test failed ; exit 1 )
$(E) "[RUN] Testing gpr_avl_test"
$(Q) $(BINDIR)/$(CONFIG)/gpr_avl_test || ( echo test gpr_avl_test failed ; exit 1 )
$(E) "[RUN] Testing gpr_cmdline_test"
$(Q) $(BINDIR)/$(CONFIG)/gpr_cmdline_test || ( echo test gpr_cmdline_test failed ; exit 1 )
$(E) "[RUN] Testing gpr_cpu_test"
@ -2874,7 +2874,6 @@ LIBGPR_SRC = \
src/core/lib/gpr/alloc.cc \
src/core/lib/gpr/arena.cc \
src/core/lib/gpr/atm.cc \
src/core/lib/gpr/avl.cc \
src/core/lib/gpr/cmdline.cc \
src/core/lib/gpr/cpu_iphone.cc \
src/core/lib/gpr/cpu_linux.cc \
@ -3019,6 +3018,7 @@ endif
LIBGRPC_SRC = \
src/core/lib/surface/init.cc \
src/core/lib/avl/avl.cc \
src/core/lib/backoff/backoff.cc \
src/core/lib/channel/channel_args.cc \
src/core/lib/channel/channel_stack.cc \
@ -3363,6 +3363,7 @@ endif
LIBGRPC_CRONET_SRC = \
src/core/lib/surface/init.cc \
src/core/lib/avl/avl.cc \
src/core/lib/backoff/backoff.cc \
src/core/lib/channel/channel_args.cc \
src/core/lib/channel/channel_stack.cc \
@ -3688,6 +3689,7 @@ LIBGRPC_TEST_UTIL_SRC = \
test/core/util/slice_splitter.cc \
test/core/util/tracer_util.cc \
test/core/util/trickle_endpoint.cc \
src/core/lib/avl/avl.cc \
src/core/lib/backoff/backoff.cc \
src/core/lib/channel/channel_args.cc \
src/core/lib/channel/channel_stack.cc \
@ -3949,6 +3951,7 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \
test/core/util/slice_splitter.cc \
test/core/util/tracer_util.cc \
test/core/util/trickle_endpoint.cc \
src/core/lib/avl/avl.cc \
src/core/lib/backoff/backoff.cc \
src/core/lib/channel/channel_args.cc \
src/core/lib/channel/channel_stack.cc \
@ -4180,6 +4183,7 @@ endif
LIBGRPC_UNSECURE_SRC = \
src/core/lib/surface/init.cc \
src/core/lib/surface/init_unsecure.cc \
src/core/lib/avl/avl.cc \
src/core/lib/backoff/backoff.cc \
src/core/lib/channel/channel_args.cc \
src/core/lib/channel/channel_stack.cc \
@ -4913,6 +4917,7 @@ LIBGRPC++_CRONET_SRC = \
src/core/ext/transport/chttp2/transport/stream_map.cc \
src/core/ext/transport/chttp2/transport/varint.cc \
src/core/ext/transport/chttp2/transport/writing.cc \
src/core/lib/avl/avl.cc \
src/core/lib/backoff/backoff.cc \
src/core/lib/channel/channel_args.cc \
src/core/lib/channel/channel_stack.cc \
@ -9404,6 +9409,38 @@ endif
endif
AVL_TEST_SRC = \
test/core/avl/avl_test.cc \
AVL_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(AVL_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/avl_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/avl_test: $(AVL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(AVL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/avl_test
endif
$(OBJDIR)/$(CONFIG)/test/core/avl/avl_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc.a
deps_avl_test: $(AVL_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(AVL_TEST_OBJS:.o=.dep)
endif
endif
BAD_SERVER_RESPONSE_TEST_SRC = \
test/core/end2end/bad_server_response_test.cc \
@ -10367,38 +10404,6 @@ endif
endif
GPR_AVL_TEST_SRC = \
test/core/gpr/avl_test.cc \
GPR_AVL_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(GPR_AVL_TEST_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
$(BINDIR)/$(CONFIG)/gpr_avl_test: openssl_dep_error
else
$(BINDIR)/$(CONFIG)/gpr_avl_test: $(GPR_AVL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
$(Q) $(LD) $(LDFLAGS) $(GPR_AVL_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_avl_test
endif
$(OBJDIR)/$(CONFIG)/test/core/gpr/avl_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
deps_gpr_avl_test: $(GPR_AVL_TEST_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
-include $(GPR_AVL_TEST_OBJS:.o=.dep)
endif
endif
GPR_CMDLINE_TEST_SRC = \
test/core/gpr/cmdline_test.cc \

@ -29,7 +29,6 @@ filegroups:
- src/core/lib/gpr/alloc.cc
- src/core/lib/gpr/arena.cc
- src/core/lib/gpr/atm.cc
- src/core/lib/gpr/avl.cc
- src/core/lib/gpr/cmdline.cc
- src/core/lib/gpr/cpu_iphone.cc
- src/core/lib/gpr/cpu_linux.cc
@ -100,7 +99,6 @@ filegroups:
- include/grpc/support/tls_pthread.h
headers:
- src/core/lib/gpr/arena.h
- src/core/lib/gpr/avl.h
- src/core/lib/gpr/env.h
- src/core/lib/gpr/fork.h
- src/core/lib/gpr/mpscq.h
@ -150,6 +148,7 @@ filegroups:
- grpc++_codegen_base
- name: grpc_base
src:
- src/core/lib/avl/avl.cc
- src/core/lib/backoff/backoff.cc
- src/core/lib/channel/channel_args.cc
- src/core/lib/channel/channel_stack.cc
@ -307,6 +306,7 @@ filegroups:
- include/grpc/status.h
- include/grpc/support/workaround_list.h
headers:
- src/core/lib/avl/avl.h
- src/core/lib/backoff/backoff.h
- src/core/lib/channel/channel_args.h
- src/core/lib/channel/channel_stack.h
@ -1762,6 +1762,16 @@ targets:
- gpr_test_util
- gpr
uses_polling: false
- name: avl_test
build: test
language: c
src:
- test/core/avl/avl_test.cc
deps:
- gpr_test_util
- gpr
- grpc
uses_polling: false
- name: bad_server_response_test
build: test
language: c
@ -2130,15 +2140,6 @@ targets:
- mac
- linux
- posix
- name: gpr_avl_test
build: test
language: c
src:
- test/core/gpr/avl_test.cc
deps:
- gpr_test_util
- gpr
uses_polling: false
- name: gpr_cmdline_test
build: test
language: c

@ -42,7 +42,6 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/gpr/alloc.cc \
src/core/lib/gpr/arena.cc \
src/core/lib/gpr/atm.cc \
src/core/lib/gpr/avl.cc \
src/core/lib/gpr/cmdline.cc \
src/core/lib/gpr/cpu_iphone.cc \
src/core/lib/gpr/cpu_linux.cc \
@ -84,6 +83,7 @@ if test "$PHP_GRPC" != "no"; then
src/core/lib/profiling/basic_timers.cc \
src/core/lib/profiling/stap_timers.cc \
src/core/lib/surface/init.cc \
src/core/lib/avl/avl.cc \
src/core/lib/backoff/backoff.cc \
src/core/lib/channel/channel_args.cc \
src/core/lib/channel/channel_stack.cc \
@ -626,6 +626,7 @@ if test "$PHP_GRPC" != "no"; then
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/server/secure)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/chttp2/transport)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/ext/transport/inproc)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/avl)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/backoff)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/channel)
PHP_ADD_BUILD_DIR($ext_builddir/src/core/lib/compression)

@ -19,7 +19,6 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\gpr\\alloc.cc " +
"src\\core\\lib\\gpr\\arena.cc " +
"src\\core\\lib\\gpr\\atm.cc " +
"src\\core\\lib\\gpr\\avl.cc " +
"src\\core\\lib\\gpr\\cmdline.cc " +
"src\\core\\lib\\gpr\\cpu_iphone.cc " +
"src\\core\\lib\\gpr\\cpu_linux.cc " +
@ -61,6 +60,7 @@ if (PHP_GRPC != "no") {
"src\\core\\lib\\profiling\\basic_timers.cc " +
"src\\core\\lib\\profiling\\stap_timers.cc " +
"src\\core\\lib\\surface\\init.cc " +
"src\\core\\lib\\avl\\avl.cc " +
"src\\core\\lib\\backoff\\backoff.cc " +
"src\\core\\lib\\channel\\channel_args.cc " +
"src\\core\\lib\\channel\\channel_stack.cc " +
@ -638,6 +638,7 @@ if (PHP_GRPC != "no") {
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\chttp2\\transport");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\ext\\transport\\inproc");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\avl");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\backoff");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\channel");
FSO.CreateFolder(base_dir+"\\ext\\grpc\\src\\core\\lib\\compression");

@ -204,7 +204,6 @@ Pod::Spec.new do |s|
'src/cpp/util/time_cc.cc',
'src/cpp/codegen/codegen_init.cc',
'src/core/lib/gpr/arena.h',
'src/core/lib/gpr/avl.h',
'src/core/lib/gpr/env.h',
'src/core/lib/gpr/fork.h',
'src/core/lib/gpr/mpscq.h',
@ -297,6 +296,7 @@ Pod::Spec.new do |s|
'src/core/ext/filters/deadline/deadline_filter.h',
'src/core/ext/transport/chttp2/client/chttp2_connector.h',
'src/core/ext/transport/inproc/inproc_transport.h',
'src/core/lib/avl/avl.h',
'src/core/lib/backoff/backoff.h',
'src/core/lib/channel/channel_args.h',
'src/core/lib/channel/channel_stack.h',
@ -451,7 +451,6 @@ Pod::Spec.new do |s|
'src/cpp/server/thread_pool_interface.h',
'src/cpp/thread_manager/thread_manager.h',
'src/core/lib/gpr/arena.h',
'src/core/lib/gpr/avl.h',
'src/core/lib/gpr/env.h',
'src/core/lib/gpr/fork.h',
'src/core/lib/gpr/mpscq.h',
@ -470,6 +469,7 @@ Pod::Spec.new do |s|
'src/core/lib/gprpp/manual_constructor.h',
'src/core/lib/gprpp/memory.h',
'src/core/lib/profiling/timers.h',
'src/core/lib/avl/avl.h',
'src/core/lib/backoff/backoff.h',
'src/core/lib/channel/channel_args.h',
'src/core/lib/channel/channel_stack.h',

@ -192,7 +192,6 @@ Pod::Spec.new do |s|
# To save you from scrolling, this is the last part of the podspec.
ss.source_files = 'src/core/lib/gpr/arena.h',
'src/core/lib/gpr/avl.h',
'src/core/lib/gpr/env.h',
'src/core/lib/gpr/fork.h',
'src/core/lib/gpr/mpscq.h',
@ -214,7 +213,6 @@ Pod::Spec.new do |s|
'src/core/lib/gpr/alloc.cc',
'src/core/lib/gpr/arena.cc',
'src/core/lib/gpr/atm.cc',
'src/core/lib/gpr/avl.cc',
'src/core/lib/gpr/cmdline.cc',
'src/core/lib/gpr/cpu_iphone.cc',
'src/core/lib/gpr/cpu_linux.cc',
@ -329,6 +327,7 @@ Pod::Spec.new do |s|
'src/core/ext/filters/deadline/deadline_filter.h',
'src/core/ext/transport/chttp2/client/chttp2_connector.h',
'src/core/ext/transport/inproc/inproc_transport.h',
'src/core/lib/avl/avl.h',
'src/core/lib/backoff/backoff.h',
'src/core/lib/channel/channel_args.h',
'src/core/lib/channel/channel_stack.h',
@ -471,6 +470,7 @@ Pod::Spec.new do |s|
'src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h',
'src/core/ext/filters/workarounds/workaround_utils.h',
'src/core/lib/surface/init.cc',
'src/core/lib/avl/avl.cc',
'src/core/lib/backoff/backoff.cc',
'src/core/lib/channel/channel_args.cc',
'src/core/lib/channel/channel_stack.cc',
@ -721,7 +721,6 @@ Pod::Spec.new do |s|
'src/core/plugin_registry/grpc_plugin_registry.cc'
ss.private_header_files = 'src/core/lib/gpr/arena.h',
'src/core/lib/gpr/avl.h',
'src/core/lib/gpr/env.h',
'src/core/lib/gpr/fork.h',
'src/core/lib/gpr/mpscq.h',
@ -814,6 +813,7 @@ Pod::Spec.new do |s|
'src/core/ext/filters/deadline/deadline_filter.h',
'src/core/ext/transport/chttp2/client/chttp2_connector.h',
'src/core/ext/transport/inproc/inproc_transport.h',
'src/core/lib/avl/avl.h',
'src/core/lib/backoff/backoff.h',
'src/core/lib/channel/channel_args.h',
'src/core/lib/channel/channel_stack.h',

@ -82,7 +82,6 @@ Gem::Specification.new do |s|
s.files += %w( include/grpc/impl/codegen/sync_posix.h )
s.files += %w( include/grpc/impl/codegen/sync_windows.h )
s.files += %w( src/core/lib/gpr/arena.h )
s.files += %w( src/core/lib/gpr/avl.h )
s.files += %w( src/core/lib/gpr/env.h )
s.files += %w( src/core/lib/gpr/fork.h )
s.files += %w( src/core/lib/gpr/mpscq.h )
@ -104,7 +103,6 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/gpr/alloc.cc )
s.files += %w( src/core/lib/gpr/arena.cc )
s.files += %w( src/core/lib/gpr/atm.cc )
s.files += %w( src/core/lib/gpr/avl.cc )
s.files += %w( src/core/lib/gpr/cmdline.cc )
s.files += %w( src/core/lib/gpr/cpu_iphone.cc )
s.files += %w( src/core/lib/gpr/cpu_linux.cc )
@ -255,6 +253,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/filters/deadline/deadline_filter.h )
s.files += %w( src/core/ext/transport/chttp2/client/chttp2_connector.h )
s.files += %w( src/core/ext/transport/inproc/inproc_transport.h )
s.files += %w( src/core/lib/avl/avl.h )
s.files += %w( src/core/lib/backoff/backoff.h )
s.files += %w( src/core/lib/channel/channel_args.h )
s.files += %w( src/core/lib/channel/channel_stack.h )
@ -401,6 +400,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h )
s.files += %w( src/core/ext/filters/workarounds/workaround_utils.h )
s.files += %w( src/core/lib/surface/init.cc )
s.files += %w( src/core/lib/avl/avl.cc )
s.files += %w( src/core/lib/backoff/backoff.cc )
s.files += %w( src/core/lib/channel/channel_args.cc )
s.files += %w( src/core/lib/channel/channel_stack.cc )

@ -164,7 +164,6 @@
'src/core/lib/gpr/alloc.cc',
'src/core/lib/gpr/arena.cc',
'src/core/lib/gpr/atm.cc',
'src/core/lib/gpr/avl.cc',
'src/core/lib/gpr/cmdline.cc',
'src/core/lib/gpr/cpu_iphone.cc',
'src/core/lib/gpr/cpu_linux.cc',
@ -225,6 +224,7 @@
],
'sources': [
'src/core/lib/surface/init.cc',
'src/core/lib/avl/avl.cc',
'src/core/lib/backoff/backoff.cc',
'src/core/lib/channel/channel_args.cc',
'src/core/lib/channel/channel_stack.cc',
@ -520,6 +520,7 @@
'test/core/util/slice_splitter.cc',
'test/core/util/tracer_util.cc',
'test/core/util/trickle_endpoint.cc',
'src/core/lib/avl/avl.cc',
'src/core/lib/backoff/backoff.cc',
'src/core/lib/channel/channel_args.cc',
'src/core/lib/channel/channel_stack.cc',
@ -733,6 +734,7 @@
'test/core/util/slice_splitter.cc',
'test/core/util/tracer_util.cc',
'test/core/util/trickle_endpoint.cc',
'src/core/lib/avl/avl.cc',
'src/core/lib/backoff/backoff.cc',
'src/core/lib/channel/channel_args.cc',
'src/core/lib/channel/channel_stack.cc',
@ -928,6 +930,7 @@
'sources': [
'src/core/lib/surface/init.cc',
'src/core/lib/surface/init_unsecure.cc',
'src/core/lib/avl/avl.cc',
'src/core/lib/backoff/backoff.cc',
'src/core/lib/channel/channel_args.cc',
'src/core/lib/channel/channel_stack.cc',

@ -89,7 +89,6 @@
<file baseinstalldir="/" name="include/grpc/impl/codegen/sync_posix.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/sync_windows.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/arena.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/avl.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/env.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/fork.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/mpscq.h" role="src" />
@ -111,7 +110,6 @@
<file baseinstalldir="/" name="src/core/lib/gpr/alloc.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/arena.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/atm.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/avl.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/cmdline.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/cpu_iphone.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/cpu_linux.cc" role="src" />
@ -262,6 +260,7 @@
<file baseinstalldir="/" name="src/core/ext/filters/deadline/deadline_filter.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/chttp2/client/chttp2_connector.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/transport/inproc/inproc_transport.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/avl/avl.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/backoff/backoff.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/channel_args.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/channel_stack.h" role="src" />
@ -408,6 +407,7 @@
<file baseinstalldir="/" name="src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h" role="src" />
<file baseinstalldir="/" name="src/core/ext/filters/workarounds/workaround_utils.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/surface/init.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/avl/avl.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/backoff/backoff.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/channel_args.cc" role="src" />
<file baseinstalldir="/" name="src/core/lib/channel/channel_stack.cc" role="src" />

@ -26,7 +26,7 @@
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
#include "src/core/lib/gpr/avl.h"
#include "src/core/lib/avl/avl.h"
//
// server_retry_throttle_data
@ -153,7 +153,7 @@ static void* copy_server_retry_throttle_data(void* value, void* unused) {
static void destroy_server_name(void* key, void* unused) { gpr_free(key); }
static const gpr_avl_vtable avl_vtable = {
static const grpc_avl_vtable avl_vtable = {
destroy_server_name, copy_server_name, compare_server_name,
destroy_server_retry_throttle_data, copy_server_retry_throttle_data};
@ -162,29 +162,29 @@ static const gpr_avl_vtable avl_vtable = {
//
static gpr_mu g_mu;
static gpr_avl g_avl;
static grpc_avl g_avl;
void grpc_retry_throttle_map_init() {
gpr_mu_init(&g_mu);
g_avl = gpr_avl_create(&avl_vtable);
g_avl = grpc_avl_create(&avl_vtable);
}
void grpc_retry_throttle_map_shutdown() {
gpr_mu_destroy(&g_mu);
gpr_avl_unref(g_avl, nullptr);
grpc_avl_unref(g_avl, nullptr);
}
grpc_server_retry_throttle_data* grpc_retry_throttle_map_get_data_for_server(
const char* server_name, int max_milli_tokens, int milli_token_ratio) {
gpr_mu_lock(&g_mu);
grpc_server_retry_throttle_data* throttle_data =
(grpc_server_retry_throttle_data*)gpr_avl_get(g_avl, (char*)server_name,
(grpc_server_retry_throttle_data*)grpc_avl_get(g_avl, (char*)server_name,
nullptr);
if (throttle_data == nullptr) {
// Entry not found. Create a new one.
throttle_data = grpc_server_retry_throttle_data_create(
max_milli_tokens, milli_token_ratio, nullptr);
g_avl = gpr_avl_add(g_avl, (char*)server_name, throttle_data, nullptr);
g_avl = grpc_avl_add(g_avl, (char*)server_name, throttle_data, nullptr);
} else {
if (throttle_data->max_milli_tokens != max_milli_tokens ||
throttle_data->milli_token_ratio != milli_token_ratio) {
@ -192,7 +192,7 @@ grpc_server_retry_throttle_data* grpc_retry_throttle_map_get_data_for_server(
// the original one.
throttle_data = grpc_server_retry_throttle_data_create(
max_milli_tokens, milli_token_ratio, throttle_data);
g_avl = gpr_avl_add(g_avl, (char*)server_name, throttle_data, nullptr);
g_avl = grpc_avl_add(g_avl, (char*)server_name, throttle_data, nullptr);
} else {
// Entry found. Increase refcount.
grpc_server_retry_throttle_data_ref(throttle_data);

@ -26,11 +26,11 @@
#include <grpc/support/tls.h>
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/gpr/avl.h"
#include "src/core/lib/avl/avl.h"
// a map of subchannel_key --> subchannel, used for detecting connections
// to the same destination in order to share them
static gpr_avl g_subchannel_index;
static grpc_avl g_subchannel_index;
static gpr_mu g_mu;
@ -109,7 +109,7 @@ static void* scv_avl_copy(void* p, void* unused) {
return p;
}
static const gpr_avl_vtable subchannel_avl_vtable = {
static const grpc_avl_vtable subchannel_avl_vtable = {
sck_avl_destroy, // destroy_key
sck_avl_copy, // copy_key
sck_avl_compare, // compare_keys
@ -118,7 +118,7 @@ static const gpr_avl_vtable subchannel_avl_vtable = {
};
void grpc_subchannel_index_init(void) {
g_subchannel_index = gpr_avl_create(&subchannel_avl_vtable);
g_subchannel_index = grpc_avl_create(&subchannel_avl_vtable);
gpr_mu_init(&g_mu);
gpr_ref_init(&g_refcount, 1);
}
@ -133,7 +133,7 @@ void grpc_subchannel_index_shutdown(void) {
void grpc_subchannel_index_unref(void) {
if (gpr_unref(&g_refcount)) {
gpr_mu_destroy(&g_mu);
gpr_avl_unref(g_subchannel_index, grpc_core::ExecCtx::Get());
grpc_avl_unref(g_subchannel_index, grpc_core::ExecCtx::Get());
}
}
@ -143,13 +143,13 @@ grpc_subchannel* grpc_subchannel_index_find(grpc_subchannel_key* key) {
// Lock, and take a reference to the subchannel index.
// We don't need to do the search under a lock as avl's are immutable.
gpr_mu_lock(&g_mu);
gpr_avl index = gpr_avl_ref(g_subchannel_index, grpc_core::ExecCtx::Get());
grpc_avl index = grpc_avl_ref(g_subchannel_index, grpc_core::ExecCtx::Get());
gpr_mu_unlock(&g_mu);
grpc_subchannel* c = GRPC_SUBCHANNEL_REF_FROM_WEAK_REF(
(grpc_subchannel*)gpr_avl_get(index, key, grpc_core::ExecCtx::Get()),
(grpc_subchannel*)grpc_avl_get(index, key, grpc_core::ExecCtx::Get()),
"index_find");
gpr_avl_unref(index, grpc_core::ExecCtx::Get());
grpc_avl_unref(index, grpc_core::ExecCtx::Get());
return c;
}
@ -165,11 +165,11 @@ grpc_subchannel* grpc_subchannel_index_register(grpc_subchannel_key* key,
// Compare and swap loop:
// - take a reference to the current index
gpr_mu_lock(&g_mu);
gpr_avl index = gpr_avl_ref(g_subchannel_index, grpc_core::ExecCtx::Get());
grpc_avl index = grpc_avl_ref(g_subchannel_index, grpc_core::ExecCtx::Get());
gpr_mu_unlock(&g_mu);
// - Check to see if a subchannel already exists
c = (grpc_subchannel*)gpr_avl_get(index, key, grpc_core::ExecCtx::Get());
c = (grpc_subchannel*)grpc_avl_get(index, key, grpc_core::ExecCtx::Get());
if (c != nullptr) {
c = GRPC_SUBCHANNEL_REF_FROM_WEAK_REF(c, "index_register");
}
@ -178,8 +178,8 @@ grpc_subchannel* grpc_subchannel_index_register(grpc_subchannel_key* key,
need_to_unref_constructed = true;
} else {
// no -> update the avl and compare/swap
gpr_avl updated =
gpr_avl_add(gpr_avl_ref(index, grpc_core::ExecCtx::Get()),
grpc_avl updated =
grpc_avl_add(grpc_avl_ref(index, grpc_core::ExecCtx::Get()),
subchannel_key_copy(key),
GRPC_SUBCHANNEL_WEAK_REF(constructed, "index_register"),
grpc_core::ExecCtx::Get());
@ -189,14 +189,14 @@ grpc_subchannel* grpc_subchannel_index_register(grpc_subchannel_key* key,
// compare/swap here to check that, and retry as necessary
gpr_mu_lock(&g_mu);
if (index.root == g_subchannel_index.root) {
GPR_SWAP(gpr_avl, updated, g_subchannel_index);
GPR_SWAP(grpc_avl, updated, g_subchannel_index);
c = constructed;
}
gpr_mu_unlock(&g_mu);
gpr_avl_unref(updated, grpc_core::ExecCtx::Get());
grpc_avl_unref(updated, grpc_core::ExecCtx::Get());
}
gpr_avl_unref(index, grpc_core::ExecCtx::Get());
grpc_avl_unref(index, grpc_core::ExecCtx::Get());
}
if (need_to_unref_constructed) {
@ -213,33 +213,33 @@ void grpc_subchannel_index_unregister(grpc_subchannel_key* key,
// Compare and swap loop:
// - take a reference to the current index
gpr_mu_lock(&g_mu);
gpr_avl index = gpr_avl_ref(g_subchannel_index, grpc_core::ExecCtx::Get());
grpc_avl index = grpc_avl_ref(g_subchannel_index, grpc_core::ExecCtx::Get());
gpr_mu_unlock(&g_mu);
// Check to see if this key still refers to the previously
// registered subchannel
grpc_subchannel* c =
(grpc_subchannel*)gpr_avl_get(index, key, grpc_core::ExecCtx::Get());
(grpc_subchannel*)grpc_avl_get(index, key, grpc_core::ExecCtx::Get());
if (c != constructed) {
gpr_avl_unref(index, grpc_core::ExecCtx::Get());
grpc_avl_unref(index, grpc_core::ExecCtx::Get());
break;
}
// compare and swap the update (some other thread may have
// mutated the index behind us)
gpr_avl updated =
gpr_avl_remove(gpr_avl_ref(index, grpc_core::ExecCtx::Get()), key,
grpc_avl updated =
grpc_avl_remove(grpc_avl_ref(index, grpc_core::ExecCtx::Get()), key,
grpc_core::ExecCtx::Get());
gpr_mu_lock(&g_mu);
if (index.root == g_subchannel_index.root) {
GPR_SWAP(gpr_avl, updated, g_subchannel_index);
GPR_SWAP(grpc_avl, updated, g_subchannel_index);
done = true;
}
gpr_mu_unlock(&g_mu);
gpr_avl_unref(updated, grpc_core::ExecCtx::Get());
gpr_avl_unref(index, grpc_core::ExecCtx::Get());
grpc_avl_unref(updated, grpc_core::ExecCtx::Get());
grpc_avl_unref(index, grpc_core::ExecCtx::Get());
}
}

@ -16,7 +16,7 @@
*
*/
#include "src/core/lib/gpr/avl.h"
#include "src/core/lib/avl/avl.h"
#include <assert.h>
#include <stdlib.h>
@ -26,21 +26,21 @@
#include "src/core/lib/gpr/useful.h"
gpr_avl gpr_avl_create(const gpr_avl_vtable* vtable) {
gpr_avl out;
grpc_avl grpc_avl_create(const grpc_avl_vtable* vtable) {
grpc_avl out;
out.vtable = vtable;
out.root = nullptr;
return out;
}
static gpr_avl_node* ref_node(gpr_avl_node* node) {
static grpc_avl_node* ref_node(grpc_avl_node* node) {
if (node) {
gpr_ref(&node->refs);
}
return node;
}
static void unref_node(const gpr_avl_vtable* vtable, gpr_avl_node* node,
static void unref_node(const grpc_avl_vtable* vtable, grpc_avl_node* node,
void* user_data) {
if (node == nullptr) {
return;
@ -54,18 +54,18 @@ static void unref_node(const gpr_avl_vtable* vtable, gpr_avl_node* node,
}
}
static long node_height(gpr_avl_node* node) {
static long node_height(grpc_avl_node* node) {
return node == nullptr ? 0 : node->height;
}
#ifndef NDEBUG
static long calculate_height(gpr_avl_node* node) {
static long calculate_height(grpc_avl_node* node) {
return node == nullptr ? 0
: 1 + GPR_MAX(calculate_height(node->left),
calculate_height(node->right));
}
static gpr_avl_node* assert_invariants(gpr_avl_node* n) {
static grpc_avl_node* assert_invariants(grpc_avl_node* n) {
if (n == nullptr) return nullptr;
assert_invariants(n->left);
assert_invariants(n->right);
@ -74,12 +74,12 @@ static gpr_avl_node* assert_invariants(gpr_avl_node* n) {
return n;
}
#else
static gpr_avl_node* assert_invariants(gpr_avl_node* n) { return n; }
static grpc_avl_node* assert_invariants(grpc_avl_node* n) { return n; }
#endif
gpr_avl_node* new_node(void* key, void* value, gpr_avl_node* left,
gpr_avl_node* right) {
gpr_avl_node* node = (gpr_avl_node*)gpr_malloc(sizeof(*node));
grpc_avl_node* new_node(void* key, void* value, grpc_avl_node* left,
grpc_avl_node* right) {
grpc_avl_node* node = (grpc_avl_node*)gpr_malloc(sizeof(*node));
gpr_ref_init(&node->refs, 1);
node->key = key;
node->value = value;
@ -89,7 +89,7 @@ gpr_avl_node* new_node(void* key, void* value, gpr_avl_node* left,
return node;
}
static gpr_avl_node* get(const gpr_avl_vtable* vtable, gpr_avl_node* node,
static grpc_avl_node* get(const grpc_avl_vtable* vtable, grpc_avl_node* node,
void* key, void* user_data) {
long cmp;
@ -107,13 +107,13 @@ static gpr_avl_node* get(const gpr_avl_vtable* vtable, gpr_avl_node* node,
}
}
void* gpr_avl_get(gpr_avl avl, void* key, void* user_data) {
gpr_avl_node* node = get(avl.vtable, avl.root, key, user_data);
void* grpc_avl_get(grpc_avl avl, void* key, void* user_data) {
grpc_avl_node* node = get(avl.vtable, avl.root, key, user_data);
return node ? node->value : nullptr;
}
int gpr_avl_maybe_get(gpr_avl avl, void* key, void** value, void* user_data) {
gpr_avl_node* node = get(avl.vtable, avl.root, key, user_data);
int grpc_avl_maybe_get(grpc_avl avl, void* key, void** value, void* user_data) {
grpc_avl_node* node = get(avl.vtable, avl.root, key, user_data);
if (node != nullptr) {
*value = node->value;
return 1;
@ -121,10 +121,10 @@ int gpr_avl_maybe_get(gpr_avl avl, void* key, void** value, void* user_data) {
return 0;
}
static gpr_avl_node* rotate_left(const gpr_avl_vtable* vtable, void* key,
void* value, gpr_avl_node* left,
gpr_avl_node* right, void* user_data) {
gpr_avl_node* n = new_node(vtable->copy_key(right->key, user_data),
static grpc_avl_node* rotate_left(const grpc_avl_vtable* vtable, void* key,
void* value, grpc_avl_node* left,
grpc_avl_node* right, void* user_data) {
grpc_avl_node* n = new_node(vtable->copy_key(right->key, user_data),
vtable->copy_value(right->value, user_data),
new_node(key, value, left, ref_node(right->left)),
ref_node(right->right));
@ -132,10 +132,10 @@ static gpr_avl_node* rotate_left(const gpr_avl_vtable* vtable, void* key,
return n;
}
static gpr_avl_node* rotate_right(const gpr_avl_vtable* vtable, void* key,
void* value, gpr_avl_node* left,
gpr_avl_node* right, void* user_data) {
gpr_avl_node* n =
static grpc_avl_node* rotate_right(const grpc_avl_vtable* vtable, void* key,
void* value, grpc_avl_node* left,
grpc_avl_node* right, void* user_data) {
grpc_avl_node* n =
new_node(vtable->copy_key(left->key, user_data),
vtable->copy_value(left->value, user_data), ref_node(left->left),
new_node(key, value, ref_node(left->right), right));
@ -143,11 +143,11 @@ static gpr_avl_node* rotate_right(const gpr_avl_vtable* vtable, void* key,
return n;
}
static gpr_avl_node* rotate_left_right(const gpr_avl_vtable* vtable, void* key,
void* value, gpr_avl_node* left,
gpr_avl_node* right, void* user_data) {
static grpc_avl_node* rotate_left_right(const grpc_avl_vtable* vtable, void* key,
void* value, grpc_avl_node* left,
grpc_avl_node* right, void* user_data) {
/* rotate_right(..., rotate_left(left), right) */
gpr_avl_node* n =
grpc_avl_node* n =
new_node(vtable->copy_key(left->right->key, user_data),
vtable->copy_value(left->right->value, user_data),
new_node(vtable->copy_key(left->key, user_data),
@ -158,11 +158,11 @@ static gpr_avl_node* rotate_left_right(const gpr_avl_vtable* vtable, void* key,
return n;
}
static gpr_avl_node* rotate_right_left(const gpr_avl_vtable* vtable, void* key,
void* value, gpr_avl_node* left,
gpr_avl_node* right, void* user_data) {
static grpc_avl_node* rotate_right_left(const grpc_avl_vtable* vtable, void* key,
void* value, grpc_avl_node* left,
grpc_avl_node* right, void* user_data) {
/* rotate_left(..., left, rotate_right(right)) */
gpr_avl_node* n =
grpc_avl_node* n =
new_node(vtable->copy_key(right->left->key, user_data),
vtable->copy_value(right->left->value, user_data),
new_node(key, value, left, ref_node(right->left->left)),
@ -173,9 +173,9 @@ static gpr_avl_node* rotate_right_left(const gpr_avl_vtable* vtable, void* key,
return n;
}
static gpr_avl_node* rebalance(const gpr_avl_vtable* vtable, void* key,
void* value, gpr_avl_node* left,
gpr_avl_node* right, void* user_data) {
static grpc_avl_node* rebalance(const grpc_avl_vtable* vtable, void* key,
void* value, grpc_avl_node* left,
grpc_avl_node* right, void* user_data) {
switch (node_height(left) - node_height(right)) {
case 2:
if (node_height(left->left) - node_height(left->right) == -1) {
@ -198,7 +198,7 @@ static gpr_avl_node* rebalance(const gpr_avl_vtable* vtable, void* key,
}
}
static gpr_avl_node* add_key(const gpr_avl_vtable* vtable, gpr_avl_node* node,
static grpc_avl_node* add_key(const grpc_avl_vtable* vtable, grpc_avl_node* node,
void* key, void* value, void* user_data) {
long cmp;
if (node == nullptr) {
@ -220,30 +220,30 @@ static gpr_avl_node* add_key(const gpr_avl_vtable* vtable, gpr_avl_node* node,
}
}
gpr_avl gpr_avl_add(gpr_avl avl, void* key, void* value, void* user_data) {
gpr_avl_node* old_root = avl.root;
grpc_avl grpc_avl_add(grpc_avl avl, void* key, void* value, void* user_data) {
grpc_avl_node* old_root = avl.root;
avl.root = add_key(avl.vtable, avl.root, key, value, user_data);
assert_invariants(avl.root);
unref_node(avl.vtable, old_root, user_data);
return avl;
}
static gpr_avl_node* in_order_head(gpr_avl_node* node) {
static grpc_avl_node* in_order_head(grpc_avl_node* node) {
while (node->left != nullptr) {
node = node->left;
}
return node;
}
static gpr_avl_node* in_order_tail(gpr_avl_node* node) {
static grpc_avl_node* in_order_tail(grpc_avl_node* node) {
while (node->right != nullptr) {
node = node->right;
}
return node;
}
static gpr_avl_node* remove_key(const gpr_avl_vtable* vtable,
gpr_avl_node* node, void* key,
static grpc_avl_node* remove_key(const grpc_avl_vtable* vtable,
grpc_avl_node* node, void* key,
void* user_data) {
long cmp;
if (node == nullptr) {
@ -256,13 +256,13 @@ static gpr_avl_node* remove_key(const gpr_avl_vtable* vtable,
} else if (node->right == nullptr) {
return ref_node(node->left);
} else if (node->left->height < node->right->height) {
gpr_avl_node* h = in_order_head(node->right);
grpc_avl_node* h = in_order_head(node->right);
return rebalance(
vtable, vtable->copy_key(h->key, user_data),
vtable->copy_value(h->value, user_data), ref_node(node->left),
remove_key(vtable, node->right, h->key, user_data), user_data);
} else {
gpr_avl_node* h = in_order_tail(node->left);
grpc_avl_node* h = in_order_tail(node->left);
return rebalance(vtable, vtable->copy_key(h->key, user_data),
vtable->copy_value(h->value, user_data),
remove_key(vtable, node->left, h->key, user_data),
@ -281,21 +281,21 @@ static gpr_avl_node* remove_key(const gpr_avl_vtable* vtable,
}
}
gpr_avl gpr_avl_remove(gpr_avl avl, void* key, void* user_data) {
gpr_avl_node* old_root = avl.root;
grpc_avl grpc_avl_remove(grpc_avl avl, void* key, void* user_data) {
grpc_avl_node* old_root = avl.root;
avl.root = remove_key(avl.vtable, avl.root, key, user_data);
assert_invariants(avl.root);
unref_node(avl.vtable, old_root, user_data);
return avl;
}
gpr_avl gpr_avl_ref(gpr_avl avl, void* user_data) {
grpc_avl grpc_avl_ref(grpc_avl avl, void* user_data) {
ref_node(avl.root);
return avl;
}
void gpr_avl_unref(gpr_avl avl, void* user_data) {
void grpc_avl_unref(grpc_avl avl, void* user_data) {
unref_node(avl.vtable, avl.root, user_data);
}
int gpr_avl_is_empty(gpr_avl avl) { return avl.root == nullptr; }
int grpc_avl_is_empty(grpc_avl avl) { return avl.root == nullptr; }

@ -16,27 +16,27 @@
*
*/
#ifndef GRPC_CORE_LIB_GPR_AVL_H
#define GRPC_CORE_LIB_GPR_AVL_H
#ifndef GRPC_CORE_LIB_GRPC_AVL_H
#define GRPC_CORE_LIB_GRPC_AVL_H
#include <grpc/support/sync.h>
/** internal node of an AVL tree */
typedef struct gpr_avl_node {
typedef struct grpc_avl_node {
gpr_refcount refs;
void* key;
void* value;
struct gpr_avl_node* left;
struct gpr_avl_node* right;
struct grpc_avl_node* left;
struct grpc_avl_node* right;
long height;
} gpr_avl_node;
} grpc_avl_node;
/** vtable for the AVL tree
* The optional user_data is propagated from the top level gpr_avl_XXX API.
* The optional user_data is propagated from the top level grpc_avl_XXX API.
* From the same API call, multiple vtable functions may be called multiple
* times.
*/
typedef struct gpr_avl_vtable {
typedef struct grpc_avl_vtable {
/** destroy a key */
void (*destroy_key)(void* key, void* user_data);
/** copy a key, returning new value */
@ -48,45 +48,45 @@ typedef struct gpr_avl_vtable {
void (*destroy_value)(void* value, void* user_data);
/** copy a value */
void* (*copy_value)(void* value, void* user_data);
} gpr_avl_vtable;
} grpc_avl_vtable;
/** "pointer" to an AVL tree - this is a reference
counted object - use gpr_avl_ref to add a reference,
gpr_avl_unref when done with a reference */
typedef struct gpr_avl {
const gpr_avl_vtable* vtable;
gpr_avl_node* root;
} gpr_avl;
counted object - use grpc_avl_ref to add a reference,
grpc_avl_unref when done with a reference */
typedef struct grpc_avl {
const grpc_avl_vtable* vtable;
grpc_avl_node* root;
} grpc_avl;
/** Create an immutable AVL tree. */
gpr_avl gpr_avl_create(const gpr_avl_vtable* vtable);
grpc_avl grpc_avl_create(const grpc_avl_vtable* vtable);
/** Add a reference to an existing tree - returns
the tree as a convenience. The optional user_data will be passed to vtable
functions. */
gpr_avl gpr_avl_ref(gpr_avl avl, void* user_data);
grpc_avl grpc_avl_ref(grpc_avl avl, void* user_data);
/** Remove a reference to a tree - destroying it if there
are no references left. The optional user_data will be passed to vtable
functions. */
void gpr_avl_unref(gpr_avl avl, void* user_data);
void grpc_avl_unref(grpc_avl avl, void* user_data);
/** Return a new tree with (key, value) added to avl.
implicitly unrefs avl to allow easy chaining.
if key exists in avl, the new tree's key entry updated
(i.e. a duplicate is not created). The optional user_data will be passed to
vtable functions. */
gpr_avl gpr_avl_add(gpr_avl avl, void* key, void* value, void* user_data);
grpc_avl grpc_avl_add(grpc_avl avl, void* key, void* value, void* user_data);
/** Return a new tree with key deleted
implicitly unrefs avl to allow easy chaining. The optional user_data will be
passed to vtable functions. */
gpr_avl gpr_avl_remove(gpr_avl avl, void* key, void* user_data);
grpc_avl grpc_avl_remove(grpc_avl avl, void* key, void* user_data);
/** Lookup key, and return the associated value.
Does not mutate avl.
Returns NULL if key is not found. The optional user_data will be passed to
vtable functions.*/
void* gpr_avl_get(gpr_avl avl, void* key, void* user_data);
void* grpc_avl_get(grpc_avl avl, void* key, void* user_data);
/** Return 1 if avl contains key, 0 otherwise; if it has the key, sets *value to
its value. The optional user_data will be passed to vtable functions. */
int gpr_avl_maybe_get(gpr_avl avl, void* key, void** value, void* user_data);
int grpc_avl_maybe_get(grpc_avl avl, void* key, void** value, void* user_data);
/** Return 1 if avl is empty, 0 otherwise */
int gpr_avl_is_empty(gpr_avl avl);
int grpc_avl_is_empty(grpc_avl avl);
#endif /* GRPC_CORE_LIB_GPR_AVL_H */
#endif /* GRPC_CORE_LIB_GRPC_AVL_H */

@ -18,7 +18,6 @@ CORE_SOURCE_FILES = [
'src/core/lib/gpr/alloc.cc',
'src/core/lib/gpr/arena.cc',
'src/core/lib/gpr/atm.cc',
'src/core/lib/gpr/avl.cc',
'src/core/lib/gpr/cmdline.cc',
'src/core/lib/gpr/cpu_iphone.cc',
'src/core/lib/gpr/cpu_linux.cc',
@ -60,6 +59,7 @@ CORE_SOURCE_FILES = [
'src/core/lib/profiling/basic_timers.cc',
'src/core/lib/profiling/stap_timers.cc',
'src/core/lib/surface/init.cc',
'src/core/lib/avl/avl.cc',
'src/core/lib/backoff/backoff.cc',
'src/core/lib/channel/channel_args.cc',
'src/core/lib/channel/channel_stack.cc',

@ -0,0 +1,30 @@
# Copyright 2018 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
load("//bazel:grpc_build_system.bzl", "grpc_cc_library", "grpc_cc_test", "grpc_cc_binary", "grpc_package")
licenses(["notice"]) # Apache v2
grpc_package(name = "test/core/avl")
grpc_cc_test(
name = "avl_test",
srcs = ["avl_test.cc"],
language = "C++",
deps = [
"//:gpr",
"//:grpc_base",
"//test/core/util:gpr_test_util",
],
)

File diff suppressed because it is too large Load Diff

@ -28,16 +28,6 @@ grpc_cc_test(
],
)
grpc_cc_test(
name = "avl_test",
srcs = ["avl_test.cc"],
language = "C++",
deps = [
"//:gpr",
"//test/core/util:gpr_test_util",
],
)
grpc_cc_test(
name = "cmdline_test",
srcs = ["cmdline_test.cc"],

File diff suppressed because it is too large Load Diff

@ -932,6 +932,7 @@ include/grpc/support/tls_msvc.h \
include/grpc/support/tls_pthread.h \
include/grpc/support/workaround_list.h \
src/core/ext/transport/inproc/inproc_transport.h \
src/core/lib/avl/avl.h \
src/core/lib/backoff/backoff.h \
src/core/lib/channel/channel_args.h \
src/core/lib/channel/channel_stack.h \
@ -951,7 +952,6 @@ src/core/lib/debug/stats.h \
src/core/lib/debug/stats_data.h \
src/core/lib/debug/trace.h \
src/core/lib/gpr/arena.h \
src/core/lib/gpr/avl.h \
src/core/lib/gpr/env.h \
src/core/lib/gpr/fork.h \
src/core/lib/gpr/mpscq.h \

@ -1029,6 +1029,8 @@ src/core/ext/transport/inproc/inproc_plugin.cc \
src/core/ext/transport/inproc/inproc_transport.cc \
src/core/ext/transport/inproc/inproc_transport.h \
src/core/lib/README.md \
src/core/lib/avl/avl.cc \
src/core/lib/avl/avl.h \
src/core/lib/backoff/backoff.cc \
src/core/lib/backoff/backoff.h \
src/core/lib/channel/README.md \
@ -1071,8 +1073,6 @@ src/core/lib/gpr/alloc.cc \
src/core/lib/gpr/arena.cc \
src/core/lib/gpr/arena.h \
src/core/lib/gpr/atm.cc \
src/core/lib/gpr/avl.cc \
src/core/lib/gpr/avl.h \
src/core/lib/gpr/cmdline.cc \
src/core/lib/gpr/cpu_iphone.cc \
src/core/lib/gpr/cpu_linux.cc \

@ -82,6 +82,22 @@
"third_party": false,
"type": "target"
},
{
"deps": [
"gpr",
"gpr_test_util",
"grpc"
],
"headers": [],
"is_filegroup": false,
"language": "c",
"name": "avl_test",
"src": [
"test/core/avl/avl_test.cc"
],
"third_party": false,
"type": "target"
},
{
"deps": [
"gpr",
@ -587,21 +603,6 @@
"third_party": false,
"type": "target"
},
{
"deps": [
"gpr",
"gpr_test_util"
],
"headers": [],
"is_filegroup": false,
"language": "c",
"name": "gpr_avl_test",
"src": [
"test/core/gpr/avl_test.cc"
],
"third_party": false,
"type": "target"
},
{
"deps": [
"gpr",
@ -8171,7 +8172,6 @@
"src/core/lib/gpr/alloc.cc",
"src/core/lib/gpr/arena.cc",
"src/core/lib/gpr/atm.cc",
"src/core/lib/gpr/avl.cc",
"src/core/lib/gpr/cmdline.cc",
"src/core/lib/gpr/cpu_iphone.cc",
"src/core/lib/gpr/cpu_linux.cc",
@ -8246,7 +8246,6 @@
"include/grpc/support/tls_msvc.h",
"include/grpc/support/tls_pthread.h",
"src/core/lib/gpr/arena.h",
"src/core/lib/gpr/avl.h",
"src/core/lib/gpr/env.h",
"src/core/lib/gpr/fork.h",
"src/core/lib/gpr/mpscq.h",
@ -8295,7 +8294,6 @@
"include/grpc/support/tls_msvc.h",
"include/grpc/support/tls_pthread.h",
"src/core/lib/gpr/arena.h",
"src/core/lib/gpr/avl.h",
"src/core/lib/gpr/env.h",
"src/core/lib/gpr/fork.h",
"src/core/lib/gpr/mpscq.h",
@ -8398,6 +8396,7 @@
"language": "c",
"name": "grpc_base",
"src": [
"src/core/lib/avl/avl.cc",
"src/core/lib/backoff/backoff.cc",
"src/core/lib/channel/channel_args.cc",
"src/core/lib/channel/channel_stack.cc",
@ -8556,6 +8555,7 @@
"include/grpc/slice_buffer.h",
"include/grpc/status.h",
"include/grpc/support/workaround_list.h",
"src/core/lib/avl/avl.h",
"src/core/lib/backoff/backoff.h",
"src/core/lib/channel/channel_args.h",
"src/core/lib/channel/channel_stack.h",
@ -8698,6 +8698,7 @@
"include/grpc/slice_buffer.h",
"include/grpc/status.h",
"include/grpc/support/workaround_list.h",
"src/core/lib/avl/avl.h",
"src/core/lib/backoff/backoff.h",
"src/core/lib/channel/channel_args.h",
"src/core/lib/channel/channel_stack.h",

@ -97,6 +97,30 @@
],
"uses_polling": false
},
{
"args": [],
"benchmark": false,
"ci_platforms": [
"linux",
"mac",
"posix",
"windows"
],
"cpu_cost": 1.0,
"exclude_configs": [],
"exclude_iomgrs": [],
"flaky": false,
"gtest": false,
"language": "c",
"name": "avl_test",
"platforms": [
"linux",
"mac",
"posix",
"windows"
],
"uses_polling": false
},
{
"args": [],
"benchmark": false,
@ -719,30 +743,6 @@
],
"uses_polling": true
},
{
"args": [],
"benchmark": false,
"ci_platforms": [
"linux",
"mac",
"posix",
"windows"
],
"cpu_cost": 1.0,
"exclude_configs": [],
"exclude_iomgrs": [],
"flaky": false,
"gtest": false,
"language": "c",
"name": "gpr_avl_test",
"platforms": [
"linux",
"mac",
"posix",
"windows"
],
"uses_polling": false
},
{
"args": [],
"benchmark": false,

Loading…
Cancel
Save