grpc 1.25.0 → 1.26.0.pre1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (278) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +782 -291
  3. data/include/grpc/impl/codegen/grpc_types.h +4 -0
  4. data/include/grpc/impl/codegen/port_platform.h +7 -0
  5. data/include/grpc/support/alloc.h +0 -16
  6. data/src/core/ext/filters/client_channel/backend_metric.cc +2 -2
  7. data/src/core/ext/filters/client_channel/backup_poller.cc +1 -1
  8. data/src/core/ext/filters/client_channel/channel_connectivity.cc +2 -2
  9. data/src/core/ext/filters/client_channel/client_channel.cc +95 -88
  10. data/src/core/ext/filters/client_channel/client_channel_channelz.cc +7 -7
  11. data/src/core/ext/filters/client_channel/client_channel_channelz.h +4 -2
  12. data/src/core/ext/filters/client_channel/client_channel_factory.cc +1 -1
  13. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +3 -3
  14. data/src/core/ext/filters/client_channel/connector.h +40 -45
  15. data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +10 -10
  16. data/src/core/ext/filters/client_channel/health/health_check_client.cc +16 -13
  17. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +66 -37
  18. data/src/core/ext/filters/client_channel/http_proxy.cc +107 -116
  19. data/src/core/ext/filters/client_channel/http_proxy.h +5 -1
  20. data/src/core/ext/filters/client_channel/lb_policy.cc +3 -3
  21. data/src/core/ext/filters/client_channel/lb_policy.h +9 -5
  22. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +10 -8
  23. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +18 -19
  24. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +4 -3
  25. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +4 -4
  26. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +1 -1
  27. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +3 -3
  28. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +3 -3
  29. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +6 -9
  30. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +368 -0
  31. data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +157 -77
  32. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +5 -5
  33. data/src/core/ext/filters/client_channel/lb_policy_registry.h +1 -1
  34. data/src/core/ext/filters/client_channel/local_subchannel_pool.cc +8 -8
  35. data/src/core/ext/filters/client_channel/proxy_mapper.h +14 -34
  36. data/src/core/ext/filters/client_channel/proxy_mapper_registry.cc +46 -79
  37. data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +23 -17
  38. data/src/core/ext/filters/client_channel/resolver.cc +2 -1
  39. data/src/core/ext/filters/client_channel/resolver.h +2 -2
  40. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -1
  41. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +4 -4
  42. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +1 -1
  43. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +13 -10
  44. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +3 -2
  45. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +9 -8
  46. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +17 -16
  47. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +2 -2
  48. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +4 -4
  49. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +9 -9
  50. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +5 -3
  51. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +1 -1
  52. data/src/core/ext/filters/client_channel/resolver_factory.h +3 -3
  53. data/src/core/ext/filters/client_channel/resolver_registry.cc +14 -12
  54. data/src/core/ext/filters/client_channel/resolver_registry.h +6 -4
  55. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +6 -6
  56. data/src/core/ext/filters/client_channel/resolver_result_parsing.h +6 -6
  57. data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +5 -5
  58. data/src/core/ext/filters/client_channel/resolving_lb_policy.h +3 -3
  59. data/src/core/ext/filters/client_channel/service_config.cc +15 -14
  60. data/src/core/ext/filters/client_channel/service_config.h +14 -19
  61. data/src/core/ext/filters/client_channel/subchannel.cc +38 -36
  62. data/src/core/ext/filters/client_channel/subchannel.h +11 -12
  63. data/src/core/ext/filters/client_channel/subchannel_interface.h +1 -1
  64. data/src/core/ext/filters/client_channel/xds/xds_api.cc +19 -9
  65. data/src/core/ext/filters/client_channel/xds/xds_api.h +19 -9
  66. data/src/core/ext/filters/client_channel/xds/xds_bootstrap.cc +3 -3
  67. data/src/core/ext/filters/client_channel/xds/xds_bootstrap.h +6 -5
  68. data/src/core/ext/filters/client_channel/xds/xds_client.cc +58 -31
  69. data/src/core/ext/filters/client_channel/xds/xds_client.h +20 -15
  70. data/src/core/ext/filters/client_channel/xds/xds_client_stats.cc +5 -3
  71. data/src/core/ext/filters/client_channel/xds/xds_client_stats.h +18 -15
  72. data/src/core/ext/filters/client_idle/client_idle_filter.cc +10 -10
  73. data/src/core/ext/filters/deadline/deadline_filter.cc +15 -13
  74. data/src/core/ext/filters/http/client/http_client_filter.cc +12 -12
  75. data/src/core/ext/filters/http/client_authority_filter.cc +3 -3
  76. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +13 -7
  77. data/src/core/ext/filters/http/server/http_server_filter.cc +14 -13
  78. data/src/core/ext/filters/max_age/max_age_filter.cc +16 -14
  79. data/src/core/ext/filters/message_size/message_size_filter.cc +10 -8
  80. data/src/core/ext/filters/message_size/message_size_filter.h +1 -1
  81. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +9 -8
  82. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +141 -174
  83. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +31 -1
  84. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +7 -6
  85. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +14 -12
  86. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +8 -5
  87. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +46 -38
  88. data/src/core/ext/transport/chttp2/transport/context_list.cc +2 -2
  89. data/src/core/ext/transport/chttp2/transport/flow_control.h +0 -5
  90. data/src/core/ext/transport/chttp2/transport/frame_data.cc +6 -7
  91. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +2 -2
  92. data/src/core/ext/transport/chttp2/transport/frame_ping.cc +1 -1
  93. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +4 -3
  94. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +5 -5
  95. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +11 -8
  96. data/src/core/ext/transport/chttp2/transport/internal.h +3 -3
  97. data/src/core/ext/transport/chttp2/transport/parsing.cc +4 -4
  98. data/src/core/ext/transport/chttp2/transport/writing.cc +3 -2
  99. data/src/core/ext/transport/inproc/inproc_transport.cc +65 -41
  100. data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c +0 -1
  101. data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.c +141 -70
  102. data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h +352 -118
  103. data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c +0 -1
  104. data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c +0 -1
  105. data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c +8 -4
  106. data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h +65 -0
  107. data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c +0 -1
  108. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c +16 -2
  109. data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h +36 -0
  110. data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c +12 -5
  111. data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h +34 -0
  112. data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c +1 -2
  113. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c +13 -12
  114. data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h +28 -24
  115. data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c +0 -1
  116. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c +5 -4
  117. data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h +13 -0
  118. data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c +0 -1
  119. data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.c +23 -23
  120. data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.h +48 -44
  121. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c +0 -1
  122. data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c +0 -1
  123. data/src/core/ext/upb-generated/envoy/type/http.upb.c +16 -0
  124. data/src/core/ext/upb-generated/envoy/type/http.upb.h +36 -0
  125. data/src/core/ext/upb-generated/envoy/type/percent.upb.c +0 -1
  126. data/src/core/ext/upb-generated/envoy/type/range.upb.c +0 -1
  127. data/src/core/lib/avl/avl.cc +1 -1
  128. data/src/core/lib/channel/channel_stack.cc +1 -1
  129. data/src/core/lib/channel/channel_stack.h +16 -4
  130. data/src/core/lib/channel/channel_trace.cc +4 -4
  131. data/src/core/lib/channel/channelz.cc +46 -46
  132. data/src/core/lib/channel/channelz.h +37 -35
  133. data/src/core/lib/channel/channelz_registry.cc +2 -2
  134. data/src/core/lib/channel/channelz_registry.h +1 -1
  135. data/src/core/lib/channel/connected_channel.cc +3 -2
  136. data/src/core/lib/channel/handshaker.cc +1 -1
  137. data/src/core/lib/channel/handshaker_registry.cc +5 -5
  138. data/src/core/lib/channel/handshaker_registry.h +3 -3
  139. data/src/core/lib/compression/message_compress.cc +3 -2
  140. data/src/core/lib/compression/stream_compression_identity.cc +5 -7
  141. data/src/core/lib/gpr/alloc.cc +4 -29
  142. data/src/core/lib/gpr/cpu_linux.cc +1 -1
  143. data/src/core/lib/gprpp/fork.cc +4 -4
  144. data/src/core/lib/gprpp/global_config_env.cc +7 -7
  145. data/src/core/lib/gprpp/global_config_env.h +2 -2
  146. data/src/core/lib/gprpp/host_port.cc +8 -8
  147. data/src/core/lib/gprpp/host_port.h +3 -3
  148. data/src/core/lib/gprpp/inlined_vector.h +13 -0
  149. data/src/core/lib/gprpp/map.h +2 -9
  150. data/src/core/lib/gprpp/memory.h +12 -98
  151. data/src/core/lib/gprpp/orphanable.h +3 -3
  152. data/src/core/lib/gprpp/ref_counted.h +3 -3
  153. data/src/core/lib/gprpp/ref_counted_ptr.h +1 -1
  154. data/src/core/lib/gprpp/string_view.h +45 -23
  155. data/src/core/lib/gprpp/thd.h +1 -1
  156. data/src/core/lib/gprpp/thd_posix.cc +6 -5
  157. data/src/core/lib/gprpp/thd_windows.cc +3 -3
  158. data/src/core/lib/http/httpcli.cc +1 -1
  159. data/src/core/lib/http/httpcli_security_connector.cc +3 -3
  160. data/src/core/lib/iomgr/buffer_list.cc +10 -5
  161. data/src/core/lib/iomgr/call_combiner.cc +7 -6
  162. data/src/core/lib/iomgr/call_combiner.h +4 -3
  163. data/src/core/lib/iomgr/cfstream_handle.cc +2 -2
  164. data/src/core/lib/iomgr/closure.h +33 -135
  165. data/src/core/lib/iomgr/combiner.cc +10 -17
  166. data/src/core/lib/iomgr/combiner.h +0 -2
  167. data/src/core/lib/iomgr/endpoint_cfstream.cc +2 -2
  168. data/src/core/lib/iomgr/endpoint_pair_posix.cc +1 -1
  169. data/src/core/lib/iomgr/ev_epoll1_linux.cc +3 -2
  170. data/src/core/lib/iomgr/ev_epollex_linux.cc +23 -13
  171. data/src/core/lib/iomgr/ev_poll_posix.cc +30 -17
  172. data/src/core/lib/iomgr/exec_ctx.cc +52 -5
  173. data/src/core/lib/iomgr/exec_ctx.h +6 -2
  174. data/src/core/lib/iomgr/executor.cc +16 -37
  175. data/src/core/lib/iomgr/executor.h +4 -7
  176. data/src/core/lib/iomgr/executor/threadpool.cc +4 -4
  177. data/src/core/lib/iomgr/iomgr_custom.cc +1 -1
  178. data/src/core/lib/iomgr/lockfree_event.cc +9 -8
  179. data/src/core/lib/iomgr/logical_thread.cc +103 -0
  180. data/src/core/lib/iomgr/logical_thread.h +52 -0
  181. data/src/core/lib/iomgr/pollset_custom.cc +5 -5
  182. data/src/core/lib/iomgr/pollset_set_custom.cc +9 -9
  183. data/src/core/lib/iomgr/pollset_windows.cc +16 -2
  184. data/src/core/lib/iomgr/port.h +3 -0
  185. data/src/core/lib/iomgr/resolve_address_custom.cc +4 -4
  186. data/src/core/lib/iomgr/resolve_address_posix.cc +8 -9
  187. data/src/core/lib/iomgr/resolve_address_windows.cc +4 -6
  188. data/src/core/lib/iomgr/resource_quota.cc +26 -21
  189. data/src/core/lib/iomgr/socket_utils_common_posix.cc +11 -0
  190. data/src/core/lib/iomgr/socket_windows.cc +2 -2
  191. data/src/core/lib/iomgr/tcp_client_cfstream.cc +2 -2
  192. data/src/core/lib/iomgr/tcp_client_custom.cc +2 -2
  193. data/src/core/lib/iomgr/tcp_client_posix.cc +5 -4
  194. data/src/core/lib/iomgr/tcp_client_windows.cc +2 -2
  195. data/src/core/lib/iomgr/tcp_custom.cc +10 -9
  196. data/src/core/lib/iomgr/tcp_posix.cc +19 -15
  197. data/src/core/lib/iomgr/tcp_server_custom.cc +3 -2
  198. data/src/core/lib/iomgr/tcp_server_posix.cc +5 -4
  199. data/src/core/lib/iomgr/tcp_server_windows.cc +5 -3
  200. data/src/core/lib/iomgr/tcp_windows.cc +16 -13
  201. data/src/core/lib/iomgr/timer_custom.cc +4 -3
  202. data/src/core/lib/iomgr/timer_generic.cc +11 -9
  203. data/src/core/lib/iomgr/udp_server.cc +16 -13
  204. data/src/core/lib/security/credentials/alts/alts_credentials.cc +8 -5
  205. data/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc +45 -57
  206. data/src/core/lib/security/credentials/composite/composite_credentials.cc +7 -6
  207. data/src/core/lib/security/credentials/credentials.cc +8 -8
  208. data/src/core/lib/security/credentials/credentials.h +5 -5
  209. data/src/core/lib/security/credentials/fake/fake_credentials.cc +5 -5
  210. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +1 -1
  211. data/src/core/lib/security/credentials/iam/iam_credentials.cc +4 -4
  212. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +4 -4
  213. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +2 -2
  214. data/src/core/lib/security/credentials/local/local_credentials.cc +3 -3
  215. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +13 -11
  216. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +6 -5
  217. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +4 -4
  218. data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +5 -5
  219. data/src/core/lib/security/credentials/tls/spiffe_credentials.cc +2 -2
  220. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +28 -22
  221. data/src/core/lib/security/security_connector/alts/alts_security_connector.h +5 -0
  222. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +10 -10
  223. data/src/core/lib/security/security_connector/load_system_roots_linux.cc +2 -1
  224. data/src/core/lib/security/security_connector/local/local_security_connector.cc +8 -8
  225. data/src/core/lib/security/security_connector/security_connector.h +1 -1
  226. data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +9 -9
  227. data/src/core/lib/security/security_connector/ssl_utils.cc +5 -4
  228. data/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +14 -15
  229. data/src/core/lib/security/transport/client_auth_filter.cc +4 -3
  230. data/src/core/lib/security/transport/secure_endpoint.cc +9 -8
  231. data/src/core/lib/security/transport/security_handshaker.cc +67 -23
  232. data/src/core/lib/security/transport/server_auth_filter.cc +6 -5
  233. data/src/core/lib/security/transport/target_authority_table.h +1 -1
  234. data/src/core/lib/slice/b64.cc +3 -4
  235. data/src/core/lib/slice/b64.h +1 -2
  236. data/src/core/lib/slice/slice.cc +8 -13
  237. data/src/core/lib/surface/call.cc +19 -19
  238. data/src/core/lib/surface/call.h +6 -7
  239. data/src/core/lib/surface/call_log_batch.cc +1 -2
  240. data/src/core/lib/surface/channel.cc +17 -18
  241. data/src/core/lib/surface/channel.h +4 -19
  242. data/src/core/lib/surface/channel_ping.cc +1 -1
  243. data/src/core/lib/surface/completion_queue.cc +21 -22
  244. data/src/core/lib/surface/completion_queue_factory.cc +1 -1
  245. data/src/core/lib/surface/init.cc +1 -1
  246. data/src/core/lib/surface/init_secure.cc +2 -2
  247. data/src/core/lib/surface/lame_client.cc +10 -12
  248. data/src/core/lib/surface/server.cc +24 -18
  249. data/src/core/lib/surface/version.cc +2 -2
  250. data/src/core/lib/transport/byte_stream.cc +2 -2
  251. data/src/core/lib/transport/byte_stream.h +2 -1
  252. data/src/core/lib/transport/connectivity_state.cc +4 -4
  253. data/src/core/lib/transport/connectivity_state.h +2 -2
  254. data/src/core/lib/transport/metadata.cc +8 -10
  255. data/src/core/lib/transport/metadata.h +5 -8
  256. data/src/core/lib/transport/metadata_batch.cc +6 -0
  257. data/src/core/lib/transport/static_metadata.cc +2 -4
  258. data/src/core/lib/transport/status_metadata.cc +7 -0
  259. data/src/core/lib/transport/status_metadata.h +18 -0
  260. data/src/core/lib/transport/transport.cc +9 -7
  261. data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -0
  262. data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +292 -43
  263. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +197 -46
  264. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +4 -2
  265. data/src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h +5 -0
  266. data/src/core/tsi/ssl/session_cache/ssl_session.h +1 -1
  267. data/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc +1 -1
  268. data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +4 -4
  269. data/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc +1 -1
  270. data/src/core/tsi/ssl_transport_security.cc +2 -1
  271. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +0 -4
  272. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +0 -6
  273. data/src/ruby/lib/grpc/version.rb +1 -1
  274. data/third_party/upb/upb/decode.c +1 -0
  275. metadata +34 -32
  276. data/src/core/ext/filters/client_channel/connector.cc +0 -41
  277. data/src/core/ext/filters/client_channel/proxy_mapper.cc +0 -48
  278. data/src/core/lib/gprpp/set.h +0 -33
@@ -77,28 +77,13 @@ void resolver_enqueue_long(grpc_closure* closure, grpc_error* error) {
77
77
  closure, error, false /* is_short */);
78
78
  }
79
79
 
80
- const grpc_closure_scheduler_vtable
81
- vtables_[static_cast<size_t>(ExecutorType::NUM_EXECUTORS)]
82
- [static_cast<size_t>(ExecutorJobType::NUM_JOB_TYPES)] = {
83
- {{&default_enqueue_short, &default_enqueue_short,
84
- "def-ex-short"},
85
- {&default_enqueue_long, &default_enqueue_long, "def-ex-long"}},
86
- {{&resolver_enqueue_short, &resolver_enqueue_short,
87
- "res-ex-short"},
88
- {&resolver_enqueue_long, &resolver_enqueue_long,
89
- "res-ex-long"}}};
90
-
91
- grpc_closure_scheduler
92
- schedulers_[static_cast<size_t>(ExecutorType::NUM_EXECUTORS)]
93
- [static_cast<size_t>(ExecutorJobType::NUM_JOB_TYPES)] = {
94
- {{&vtables_[static_cast<size_t>(ExecutorType::DEFAULT)]
95
- [static_cast<size_t>(ExecutorJobType::SHORT)]},
96
- {&vtables_[static_cast<size_t>(ExecutorType::DEFAULT)]
97
- [static_cast<size_t>(ExecutorJobType::LONG)]}},
98
- {{&vtables_[static_cast<size_t>(ExecutorType::RESOLVER)]
99
- [static_cast<size_t>(ExecutorJobType::SHORT)]},
100
- {&vtables_[static_cast<size_t>(ExecutorType::RESOLVER)]
101
- [static_cast<size_t>(ExecutorJobType::LONG)]}}};
80
+ using EnqueueFunc = void (*)(grpc_closure* closure, grpc_error* error);
81
+
82
+ const EnqueueFunc
83
+ executor_enqueue_fns_[static_cast<size_t>(ExecutorType::NUM_EXECUTORS)]
84
+ [static_cast<size_t>(ExecutorJobType::NUM_JOB_TYPES)] =
85
+ {{default_enqueue_short, default_enqueue_long},
86
+ {resolver_enqueue_short, resolver_enqueue_long}};
102
87
 
103
88
  } // namespace
104
89
 
@@ -408,9 +393,9 @@ void Executor::InitAll() {
408
393
  }
409
394
 
410
395
  executors[static_cast<size_t>(ExecutorType::DEFAULT)] =
411
- grpc_core::New<Executor>("default-executor");
396
+ new Executor("default-executor");
412
397
  executors[static_cast<size_t>(ExecutorType::RESOLVER)] =
413
- grpc_core::New<Executor>("resolver-executor");
398
+ new Executor("resolver-executor");
414
399
 
415
400
  executors[static_cast<size_t>(ExecutorType::DEFAULT)]->Init();
416
401
  executors[static_cast<size_t>(ExecutorType::RESOLVER)]->Init();
@@ -418,14 +403,10 @@ void Executor::InitAll() {
418
403
  EXECUTOR_TRACE0("Executor::InitAll() done");
419
404
  }
420
405
 
421
- grpc_closure_scheduler* Executor::Scheduler(ExecutorType executor_type,
422
- ExecutorJobType job_type) {
423
- return &schedulers_[static_cast<size_t>(executor_type)]
424
- [static_cast<size_t>(job_type)];
425
- }
426
-
427
- grpc_closure_scheduler* Executor::Scheduler(ExecutorJobType job_type) {
428
- return Executor::Scheduler(ExecutorType::DEFAULT, job_type);
406
+ void Executor::Run(grpc_closure* closure, grpc_error* error,
407
+ ExecutorType executor_type, ExecutorJobType job_type) {
408
+ executor_enqueue_fns_[static_cast<size_t>(executor_type)]
409
+ [static_cast<size_t>(job_type)](closure, error);
429
410
  }
430
411
 
431
412
  void Executor::ShutdownAll() {
@@ -444,7 +425,7 @@ void Executor::ShutdownAll() {
444
425
  // Delete the executor objects.
445
426
  //
446
427
  // NOTE: It is important to call Shutdown() on all executors first before
447
- // calling Delete() because it is possible for one executor (that is not
428
+ // calling delete because it is possible for one executor (that is not
448
429
  // shutdown yet) to call Enqueue() on a different executor which is already
449
430
  // shutdown. This is legal and in such cases, the Enqueue() operation
450
431
  // effectively "fails" and enqueues that closure on the calling thread's
@@ -453,10 +434,8 @@ void Executor::ShutdownAll() {
453
434
  // By ensuring that all executors are shutdown first, we are also ensuring
454
435
  // that no thread is active across all executors.
455
436
 
456
- grpc_core::Delete<Executor>(
457
- executors[static_cast<size_t>(ExecutorType::DEFAULT)]);
458
- grpc_core::Delete<Executor>(
459
- executors[static_cast<size_t>(ExecutorType::RESOLVER)]);
437
+ delete executors[static_cast<size_t>(ExecutorType::DEFAULT)];
438
+ delete executors[static_cast<size_t>(ExecutorType::RESOLVER)];
460
439
  executors[static_cast<size_t>(ExecutorType::DEFAULT)] = nullptr;
461
440
  executors[static_cast<size_t>(ExecutorType::RESOLVER)] = nullptr;
462
441
 
@@ -83,6 +83,10 @@ class Executor {
83
83
  // Initialize ALL the executors
84
84
  static void InitAll();
85
85
 
86
+ static void Run(grpc_closure* closure, grpc_error* error,
87
+ ExecutorType executor_type = ExecutorType::DEFAULT,
88
+ ExecutorJobType job_type = ExecutorJobType::SHORT);
89
+
86
90
  // Shutdown ALL the executors
87
91
  static void ShutdownAll();
88
92
 
@@ -92,13 +96,6 @@ class Executor {
92
96
  // Set the threading mode for ALL the executors
93
97
  static void SetThreadingDefault(bool enable);
94
98
 
95
- // Get the DEFAULT executor scheduler for the given job_type
96
- static grpc_closure_scheduler* Scheduler(ExecutorJobType job_type);
97
-
98
- // Get the executor scheduler for a given executor_type and a job_type
99
- static grpc_closure_scheduler* Scheduler(ExecutorType executor_type,
100
- ExecutorJobType job_type);
101
-
102
99
  // Return if a given executor is running in threaded mode (i.e if
103
100
  // SetThreading(true) was called previously on that executor)
104
101
  static bool IsThreaded(ExecutorType executor_type);
@@ -54,11 +54,11 @@ void ThreadPool::SharedThreadPoolConstructor() {
54
54
  // Create at least 1 worker thread.
55
55
  if (num_threads_ <= 0) num_threads_ = 1;
56
56
 
57
- queue_ = New<InfLenFIFOQueue>();
57
+ queue_ = new InfLenFIFOQueue();
58
58
  threads_ = static_cast<ThreadPoolWorker**>(
59
59
  gpr_zalloc(num_threads_ * sizeof(ThreadPoolWorker*)));
60
60
  for (int i = 0; i < num_threads_; ++i) {
61
- threads_[i] = New<ThreadPoolWorker>(thd_name_, queue_, thread_options_, i);
61
+ threads_[i] = new ThreadPoolWorker(thd_name_, queue_, thread_options_, i);
62
62
  threads_[i]->Start();
63
63
  }
64
64
  }
@@ -114,10 +114,10 @@ ThreadPool::~ThreadPool() {
114
114
  }
115
115
 
116
116
  for (int i = 0; i < num_threads_; ++i) {
117
- Delete(threads_[i]);
117
+ delete threads_[i];
118
118
  }
119
119
  gpr_free(threads_);
120
- Delete(queue_);
120
+ delete queue_;
121
121
  }
122
122
 
123
123
  void ThreadPool::Add(grpc_experimental_completion_queue_functor* closure) {
@@ -45,7 +45,7 @@ static bool iomgr_platform_is_any_background_poller_thread(void) {
45
45
  return false;
46
46
  }
47
47
  static bool iomgr_platform_add_closure_to_background_poller(
48
- grpc_closure* closure, grpc_error* error) {
48
+ grpc_closure* /*closure*/, grpc_error* /*error*/) {
49
49
  return false;
50
50
  }
51
51
 
@@ -23,6 +23,7 @@
23
23
  #include <grpc/support/log.h>
24
24
 
25
25
  #include "src/core/lib/debug/trace.h"
26
+ #include "src/core/lib/iomgr/exec_ctx.h"
26
27
 
27
28
  extern grpc_core::DebugOnlyTraceFlag grpc_polling_trace;
28
29
 
@@ -124,7 +125,7 @@ void LockfreeEvent::NotifyOn(grpc_closure* closure) {
124
125
  closure when transitioning out of CLOSURE_NO_READY state (i.e there
125
126
  is no other code that needs to 'happen-after' this) */
126
127
  if (gpr_atm_no_barrier_cas(&state_, kClosureReady, kClosureNotReady)) {
127
- GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_NONE);
128
+ ExecCtx::Run(DEBUG_LOCATION, closure, GRPC_ERROR_NONE);
128
129
  return; /* Successful. Return */
129
130
  }
130
131
 
@@ -137,9 +138,9 @@ void LockfreeEvent::NotifyOn(grpc_closure* closure) {
137
138
  schedule the closure with the shutdown error */
138
139
  if ((curr & kShutdownBit) > 0) {
139
140
  grpc_error* shutdown_err = (grpc_error*)(curr & ~kShutdownBit);
140
- GRPC_CLOSURE_SCHED(closure,
141
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
142
- "FD Shutdown", &shutdown_err, 1));
141
+ ExecCtx::Run(DEBUG_LOCATION, closure,
142
+ GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
143
+ "FD Shutdown", &shutdown_err, 1));
143
144
  return;
144
145
  }
145
146
 
@@ -189,9 +190,9 @@ bool LockfreeEvent::SetShutdown(grpc_error* shutdown_err) {
189
190
  happens-after on that edge), and a release to pair with anything
190
191
  loading the shutdown state. */
191
192
  if (gpr_atm_full_cas(&state_, curr, new_state)) {
192
- GRPC_CLOSURE_SCHED((grpc_closure*)curr,
193
- GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
194
- "FD Shutdown", &shutdown_err, 1));
193
+ ExecCtx::Run(DEBUG_LOCATION, (grpc_closure*)curr,
194
+ GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
195
+ "FD Shutdown", &shutdown_err, 1));
195
196
  return true;
196
197
  }
197
198
 
@@ -239,7 +240,7 @@ void LockfreeEvent::SetReady() {
239
240
  spurious set_ready; release pairs with this or the acquire in
240
241
  notify_on (or set_shutdown) */
241
242
  else if (gpr_atm_full_cas(&state_, curr, kClosureNotReady)) {
242
- GRPC_CLOSURE_SCHED((grpc_closure*)curr, GRPC_ERROR_NONE);
243
+ ExecCtx::Run(DEBUG_LOCATION, (grpc_closure*)curr, GRPC_ERROR_NONE);
243
244
  return;
244
245
  }
245
246
  /* else the state changed again (only possible by either a racing
@@ -0,0 +1,103 @@
1
+ /*
2
+ *
3
+ * Copyright 2019 gRPC authors.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+
19
+ #include <grpc/support/port_platform.h>
20
+
21
+ #include "src/core/lib/iomgr/logical_thread.h"
22
+
23
+ namespace grpc_core {
24
+
25
+ DebugOnlyTraceFlag grpc_logical_thread_trace(false, "logical_thread");
26
+
27
+ struct CallbackWrapper {
28
+ CallbackWrapper(std::function<void()> cb, const grpc_core::DebugLocation& loc)
29
+ : callback(std::move(cb)), location(loc) {}
30
+
31
+ MultiProducerSingleConsumerQueue::Node mpscq_node;
32
+ const std::function<void()> callback;
33
+ const DebugLocation location;
34
+ };
35
+
36
+ void LogicalThread::Run(std::function<void()> callback,
37
+ const grpc_core::DebugLocation& location) {
38
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_logical_thread_trace)) {
39
+ gpr_log(GPR_INFO, "LogicalThread::Run() %p Scheduling callback [%s:%d]",
40
+ this, location.file(), location.line());
41
+ }
42
+ const size_t prev_size = size_.FetchAdd(1);
43
+ if (prev_size == 0) {
44
+ // There is no other closure executing right now on this logical thread.
45
+ // Execute this closure immediately.
46
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_logical_thread_trace)) {
47
+ gpr_log(GPR_INFO, " Executing immediately");
48
+ }
49
+ callback();
50
+ // Loan this thread to the logical thread and drain the queue.
51
+ DrainQueue();
52
+ } else {
53
+ CallbackWrapper* cb_wrapper =
54
+ new CallbackWrapper(std::move(callback), location);
55
+ // There already are closures executing on this logical thread. Simply add
56
+ // this closure to the queue.
57
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_logical_thread_trace)) {
58
+ gpr_log(GPR_INFO, " Scheduling on queue : item %p", cb_wrapper);
59
+ }
60
+ queue_.Push(&cb_wrapper->mpscq_node);
61
+ }
62
+ }
63
+
64
+ // The thread that calls this loans itself to the logical thread so as to
65
+ // execute all the scheduled callback. This is called from within
66
+ // LogicalThread::Run() after executing a callback immediately, and hence size_
67
+ // is atleast 1.
68
+ void LogicalThread::DrainQueue() {
69
+ while (true) {
70
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_logical_thread_trace)) {
71
+ gpr_log(GPR_INFO, "LogicalThread::DrainQueue() %p", this);
72
+ }
73
+ size_t prev_size = size_.FetchSub(1);
74
+ // prev_size should be atleast 1 since
75
+ GPR_DEBUG_ASSERT(prev_size >= 1);
76
+ if (prev_size == 1) {
77
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_logical_thread_trace)) {
78
+ gpr_log(GPR_INFO, " Queue Drained");
79
+ }
80
+ break;
81
+ }
82
+ // There is atleast one callback on the queue. Pop the callback from the
83
+ // queue and execute it.
84
+ CallbackWrapper* cb_wrapper = nullptr;
85
+ bool empty_unused;
86
+ while ((cb_wrapper = reinterpret_cast<CallbackWrapper*>(
87
+ queue_.PopAndCheckEnd(&empty_unused))) == nullptr) {
88
+ // This can happen either due to a race condition within the mpscq
89
+ // implementation or because of a race with Run()
90
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_logical_thread_trace)) {
91
+ gpr_log(GPR_INFO, " Queue returned nullptr, trying again");
92
+ }
93
+ }
94
+ if (GRPC_TRACE_FLAG_ENABLED(grpc_logical_thread_trace)) {
95
+ gpr_log(GPR_INFO, " Running item %p : callback scheduled at [%s:%d]",
96
+ cb_wrapper, cb_wrapper->location.file(),
97
+ cb_wrapper->location.line());
98
+ }
99
+ cb_wrapper->callback();
100
+ delete cb_wrapper;
101
+ }
102
+ }
103
+ } // namespace grpc_core
@@ -0,0 +1,52 @@
1
+ /*
2
+ *
3
+ * Copyright 2019 gRPC authors.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ */
18
+
19
+ #include <grpc/support/port_platform.h>
20
+
21
+ #include <functional>
22
+
23
+ #include "src/core/lib/debug/trace.h"
24
+ #include "src/core/lib/gprpp/atomic.h"
25
+ #include "src/core/lib/gprpp/debug_location.h"
26
+ #include "src/core/lib/gprpp/mpscq.h"
27
+ #include "src/core/lib/gprpp/ref_counted.h"
28
+
29
+ #ifndef GRPC_CORE_LIB_IOMGR_LOGICAL_THREAD_H
30
+ #define GRPC_CORE_LIB_IOMGR_LOGICAL_THREAD_H
31
+
32
+ namespace grpc_core {
33
+ extern DebugOnlyTraceFlag grpc_logical_thread_trace;
34
+
35
+ // LogicalThread is a mechanism to schedule callbacks in a synchronized manner.
36
+ // All callbacks scheduled on a LogicalThread instance will be executed serially
37
+ // in a borrowed thread. The API provides a FIFO guarantee to the execution of
38
+ // callbacks scheduled on the thread.
39
+ class LogicalThread : public RefCounted<LogicalThread> {
40
+ public:
41
+ void Run(std::function<void()> callback,
42
+ const grpc_core::DebugLocation& location);
43
+
44
+ private:
45
+ void DrainQueue();
46
+
47
+ Atomic<size_t> size_{0};
48
+ MultiProducerSingleConsumerQueue queue_;
49
+ };
50
+ } /* namespace grpc_core */
51
+
52
+ #endif /* GRPC_CORE_LIB_IOMGR_LOGICAL_THREAD_H */
@@ -53,9 +53,9 @@ static void pollset_init(grpc_pollset* pollset, gpr_mu** mu) {
53
53
  *mu = &pollset->mu;
54
54
  }
55
55
 
56
- static void pollset_shutdown(grpc_pollset* pollset, grpc_closure* closure) {
56
+ static void pollset_shutdown(grpc_pollset* /*pollset*/, grpc_closure* closure) {
57
57
  GRPC_CUSTOM_IOMGR_ASSERT_SAME_THREAD();
58
- GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_NONE);
58
+ grpc_core::ExecCtx::Run(DEBUG_LOCATION, closure, GRPC_ERROR_NONE);
59
59
  }
60
60
 
61
61
  static void pollset_destroy(grpc_pollset* pollset) {
@@ -64,7 +64,7 @@ static void pollset_destroy(grpc_pollset* pollset) {
64
64
  }
65
65
 
66
66
  static grpc_error* pollset_work(grpc_pollset* pollset,
67
- grpc_pollset_worker** worker_hdl,
67
+ grpc_pollset_worker** /*worker_hdl*/,
68
68
  grpc_millis deadline) {
69
69
  GRPC_CUSTOM_IOMGR_ASSERT_SAME_THREAD();
70
70
  gpr_mu_unlock(&pollset->mu);
@@ -87,8 +87,8 @@ static grpc_error* pollset_work(grpc_pollset* pollset,
87
87
  return GRPC_ERROR_NONE;
88
88
  }
89
89
 
90
- static grpc_error* pollset_kick(grpc_pollset* pollset,
91
- grpc_pollset_worker* specific_worker) {
90
+ static grpc_error* pollset_kick(grpc_pollset* /*pollset*/,
91
+ grpc_pollset_worker* /*specific_worker*/) {
92
92
  GRPC_CUSTOM_IOMGR_ASSERT_SAME_THREAD();
93
93
  poller_vtable->kick();
94
94
  return GRPC_ERROR_NONE;
@@ -26,19 +26,19 @@ grpc_pollset_set* pollset_set_create(void) {
26
26
  return (grpc_pollset_set*)((intptr_t)0xdeafbeef);
27
27
  }
28
28
 
29
- void pollset_set_destroy(grpc_pollset_set* pollset_set) {}
29
+ void pollset_set_destroy(grpc_pollset_set* /*pollset_set*/) {}
30
30
 
31
- void pollset_set_add_pollset(grpc_pollset_set* pollset_set,
32
- grpc_pollset* pollset) {}
31
+ void pollset_set_add_pollset(grpc_pollset_set* /*pollset_set*/,
32
+ grpc_pollset* /*pollset*/) {}
33
33
 
34
- void pollset_set_del_pollset(grpc_pollset_set* pollset_set,
35
- grpc_pollset* pollset) {}
34
+ void pollset_set_del_pollset(grpc_pollset_set* /*pollset_set*/,
35
+ grpc_pollset* /*pollset*/) {}
36
36
 
37
- void pollset_set_add_pollset_set(grpc_pollset_set* bag,
38
- grpc_pollset_set* item) {}
37
+ void pollset_set_add_pollset_set(grpc_pollset_set* /*bag*/,
38
+ grpc_pollset_set* /*item*/) {}
39
39
 
40
- void pollset_set_del_pollset_set(grpc_pollset_set* bag,
41
- grpc_pollset_set* item) {}
40
+ void pollset_set_del_pollset_set(grpc_pollset_set* /*bag*/,
41
+ grpc_pollset_set* /*item*/) {}
42
42
 
43
43
  static grpc_pollset_set_vtable vtable = {
44
44
  pollset_set_create, pollset_set_destroy,
@@ -98,7 +98,7 @@ static void pollset_shutdown(grpc_pollset* pollset, grpc_closure* closure) {
98
98
  pollset->shutting_down = 1;
99
99
  grpc_pollset_kick(pollset, GRPC_POLLSET_KICK_BROADCAST);
100
100
  if (!pollset->is_iocp_worker) {
101
- GRPC_CLOSURE_SCHED(closure, GRPC_ERROR_NONE);
101
+ grpc_core::ExecCtx::Run(DEBUG_LOCATION, closure, GRPC_ERROR_NONE);
102
102
  } else {
103
103
  pollset->on_shutdown = closure;
104
104
  }
@@ -146,7 +146,8 @@ static grpc_error* pollset_work(grpc_pollset* pollset,
146
146
  }
147
147
 
148
148
  if (pollset->shutting_down && pollset->on_shutdown != NULL) {
149
- GRPC_CLOSURE_SCHED(pollset->on_shutdown, GRPC_ERROR_NONE);
149
+ grpc_core::ExecCtx::Run(DEBUG_LOCATION, pollset->on_shutdown,
150
+ GRPC_ERROR_NONE);
150
151
  pollset->on_shutdown = NULL;
151
152
  }
152
153
  goto done;
@@ -184,19 +185,23 @@ done:
184
185
 
185
186
  static grpc_error* pollset_kick(grpc_pollset* p,
186
187
  grpc_pollset_worker* specific_worker) {
188
+ bool should_kick_global = false;
187
189
  if (specific_worker != NULL) {
188
190
  if (specific_worker == GRPC_POLLSET_KICK_BROADCAST) {
191
+ should_kick_global = true;
189
192
  for (specific_worker =
190
193
  p->root_worker.links[GRPC_POLLSET_WORKER_LINK_POLLSET].next;
191
194
  specific_worker != &p->root_worker;
192
195
  specific_worker =
193
196
  specific_worker->links[GRPC_POLLSET_WORKER_LINK_POLLSET].next) {
194
197
  specific_worker->kicked = 1;
198
+ should_kick_global = false;
195
199
  gpr_cv_signal(&specific_worker->cv);
196
200
  }
197
201
  p->kicked_without_pollers = 1;
198
202
  if (p->is_iocp_worker) {
199
203
  grpc_iocp_kick();
204
+ should_kick_global = false;
200
205
  }
201
206
  } else {
202
207
  if (p->is_iocp_worker && g_active_poller == specific_worker) {
@@ -215,6 +220,15 @@ static grpc_error* pollset_kick(grpc_pollset* p,
215
220
  grpc_iocp_kick();
216
221
  } else {
217
222
  p->kicked_without_pollers = 1;
223
+ should_kick_global = true;
224
+ }
225
+ }
226
+ if (should_kick_global && g_active_poller == NULL) {
227
+ grpc_pollset_worker* next_global_worker = pop_front_worker(
228
+ &g_global_root_worker, GRPC_POLLSET_WORKER_LINK_GLOBAL);
229
+ if (next_global_worker != NULL) {
230
+ next_global_worker->kicked = 1;
231
+ gpr_cv_signal(&next_global_worker->cv);
218
232
  }
219
233
  }
220
234
  return GRPC_ERROR_NONE;