grpc 1.8.7 → 1.9.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 (488) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +549 -325
  3. data/include/grpc/impl/codegen/grpc_types.h +1 -2
  4. data/include/grpc/impl/codegen/port_platform.h +46 -5
  5. data/include/grpc/impl/codegen/slice.h +1 -2
  6. data/include/grpc/module.modulemap +0 -2
  7. data/include/grpc/slice_buffer.h +1 -2
  8. data/include/grpc/support/log.h +4 -2
  9. data/include/grpc/support/thd.h +4 -1
  10. data/include/grpc/support/tls.h +6 -0
  11. data/include/grpc/support/tls_gcc.h +5 -40
  12. data/include/grpc/support/tls_msvc.h +9 -0
  13. data/include/grpc/support/tls_pthread.h +9 -0
  14. data/src/core/ext/filters/client_channel/backup_poller.cc +32 -29
  15. data/src/core/ext/filters/client_channel/backup_poller.h +2 -2
  16. data/src/core/ext/filters/client_channel/channel_connectivity.cc +26 -32
  17. data/src/core/ext/filters/client_channel/client_channel.cc +325 -356
  18. data/src/core/ext/filters/client_channel/client_channel.h +4 -12
  19. data/src/core/ext/filters/client_channel/client_channel_factory.cc +9 -14
  20. data/src/core/ext/filters/client_channel/client_channel_factory.h +7 -20
  21. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +7 -10
  22. data/src/core/ext/filters/client_channel/connector.cc +6 -7
  23. data/src/core/ext/filters/client_channel/connector.h +6 -16
  24. data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +38 -50
  25. data/src/core/ext/filters/client_channel/http_connect_handshaker.h +0 -8
  26. data/src/core/ext/filters/client_channel/http_proxy.cc +9 -13
  27. data/src/core/ext/filters/client_channel/http_proxy.h +0 -8
  28. data/src/core/ext/filters/client_channel/lb_policy.cc +72 -94
  29. data/src/core/ext/filters/client_channel/lb_policy.h +83 -92
  30. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +14 -19
  31. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.h +0 -8
  32. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +474 -591
  33. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.h +0 -8
  34. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.h +2 -10
  35. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +6 -6
  36. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +0 -8
  37. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +0 -9
  38. data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +0 -9
  39. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.c +3 -4
  40. data/src/core/ext/filters/client_channel/lb_policy/grpclb/proto/grpc/lb/v1/load_balancer.pb.h +9 -12
  41. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +160 -182
  42. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +182 -221
  43. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.cc +24 -35
  44. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +9 -20
  45. data/src/core/ext/filters/client_channel/lb_policy_factory.cc +6 -9
  46. data/src/core/ext/filters/client_channel/lb_policy_factory.h +4 -15
  47. data/src/core/ext/filters/client_channel/lb_policy_registry.cc +3 -3
  48. data/src/core/ext/filters/client_channel/lb_policy_registry.h +1 -9
  49. data/src/core/ext/filters/client_channel/parse_address.cc +1 -1
  50. data/src/core/ext/filters/client_channel/parse_address.h +0 -8
  51. data/src/core/ext/filters/client_channel/proxy_mapper.cc +6 -8
  52. data/src/core/ext/filters/client_channel/proxy_mapper.h +6 -16
  53. data/src/core/ext/filters/client_channel/proxy_mapper_registry.cc +13 -17
  54. data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +2 -12
  55. data/src/core/ext/filters/client_channel/resolver.cc +11 -13
  56. data/src/core/ext/filters/client_channel/resolver.h +14 -25
  57. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +57 -70
  58. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +2 -12
  59. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +23 -31
  60. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +27 -45
  61. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +5 -15
  62. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +9 -11
  63. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +53 -66
  64. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +25 -33
  65. data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h +1 -9
  66. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +26 -35
  67. data/src/core/ext/filters/client_channel/resolver_factory.cc +2 -3
  68. data/src/core/ext/filters/client_channel/resolver_factory.h +2 -12
  69. data/src/core/ext/filters/client_channel/resolver_registry.cc +12 -15
  70. data/src/core/ext/filters/client_channel/resolver_registry.h +3 -12
  71. data/src/core/ext/filters/client_channel/retry_throttle.h +0 -8
  72. data/src/core/ext/filters/client_channel/subchannel.cc +289 -301
  73. data/src/core/ext/filters/client_channel/subchannel.h +57 -84
  74. data/src/core/ext/filters/client_channel/subchannel_index.cc +30 -33
  75. data/src/core/ext/filters/client_channel/subchannel_index.h +4 -16
  76. data/src/core/ext/filters/client_channel/uri_parser.cc +13 -17
  77. data/src/core/ext/filters/client_channel/uri_parser.h +1 -10
  78. data/src/core/ext/filters/deadline/deadline_filter.cc +49 -67
  79. data/src/core/ext/filters/deadline/deadline_filter.h +4 -14
  80. data/src/core/ext/filters/http/client/http_client_filter.cc +60 -77
  81. data/src/core/ext/filters/http/client/http_client_filter.h +0 -8
  82. data/src/core/ext/filters/http/http_filters_plugin.cc +4 -6
  83. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +63 -79
  84. data/src/core/ext/filters/http/message_compress/message_compress_filter.h +0 -8
  85. data/src/core/ext/filters/http/server/http_server_filter.cc +57 -71
  86. data/src/core/ext/filters/http/server/http_server_filter.h +0 -8
  87. data/src/core/ext/filters/load_reporting/server_load_reporting_filter.cc +19 -24
  88. data/src/core/ext/filters/load_reporting/server_load_reporting_filter.h +0 -8
  89. data/src/core/ext/filters/load_reporting/server_load_reporting_plugin.cc +3 -3
  90. data/src/core/ext/filters/load_reporting/server_load_reporting_plugin.h +0 -8
  91. data/src/core/ext/filters/max_age/max_age_filter.cc +49 -62
  92. data/src/core/ext/filters/max_age/max_age_filter.h +0 -8
  93. data/src/core/ext/filters/message_size/message_size_filter.cc +23 -29
  94. data/src/core/ext/filters/message_size/message_size_filter.h +0 -8
  95. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +15 -18
  96. data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.h +0 -8
  97. data/src/core/ext/filters/workarounds/workaround_utils.h +0 -8
  98. data/src/core/ext/transport/chttp2/alpn/alpn.h +0 -8
  99. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +33 -40
  100. data/src/core/ext/transport/chttp2/client/chttp2_connector.h +0 -8
  101. data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +15 -17
  102. data/src/core/ext/transport/chttp2/client/insecure/channel_create_posix.cc +8 -8
  103. data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +23 -28
  104. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +50 -57
  105. data/src/core/ext/transport/chttp2/server/chttp2_server.h +1 -10
  106. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2.cc +3 -3
  107. data/src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.cc +7 -10
  108. data/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.cc +5 -6
  109. data/src/core/ext/transport/chttp2/transport/bin_decoder.cc +7 -9
  110. data/src/core/ext/transport/chttp2/transport/bin_decoder.h +2 -11
  111. data/src/core/ext/transport/chttp2/transport/bin_encoder.h +1 -9
  112. data/src/core/ext/transport/chttp2/transport/chttp2_plugin.cc +10 -2
  113. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +516 -636
  114. data/src/core/ext/transport/chttp2/transport/chttp2_transport.h +4 -11
  115. data/src/core/ext/transport/chttp2/transport/flow_control.cc +29 -13
  116. data/src/core/ext/transport/chttp2/transport/flow_control.h +196 -53
  117. data/src/core/ext/transport/chttp2/transport/frame.h +0 -8
  118. data/src/core/ext/transport/chttp2/transport/frame_data.cc +31 -33
  119. data/src/core/ext/transport/chttp2/transport/frame_data.h +3 -12
  120. data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +2 -3
  121. data/src/core/ext/transport/chttp2/transport/frame_goaway.h +1 -10
  122. data/src/core/ext/transport/chttp2/transport/frame_ping.cc +5 -6
  123. data/src/core/ext/transport/chttp2/transport/frame_ping.h +1 -9
  124. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.cc +2 -3
  125. data/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +1 -10
  126. data/src/core/ext/transport/chttp2/transport/frame_settings.cc +8 -3
  127. data/src/core/ext/transport/chttp2/transport/frame_settings.h +1 -10
  128. data/src/core/ext/transport/chttp2/transport/frame_window_update.cc +8 -8
  129. data/src/core/ext/transport/chttp2/transport/frame_window_update.h +5 -11
  130. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +63 -81
  131. data/src/core/ext/transport/chttp2/transport/hpack_encoder.h +2 -12
  132. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +230 -318
  133. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +6 -19
  134. data/src/core/ext/transport/chttp2/transport/hpack_table.cc +14 -20
  135. data/src/core/ext/transport/chttp2/transport/hpack_table.h +5 -16
  136. data/src/core/ext/transport/chttp2/transport/http2_settings.h +0 -7
  137. data/src/core/ext/transport/chttp2/transport/huffsyms.h +0 -8
  138. data/src/core/ext/transport/chttp2/transport/incoming_metadata.cc +8 -11
  139. data/src/core/ext/transport/chttp2/transport/incoming_metadata.h +4 -13
  140. data/src/core/ext/transport/chttp2/transport/internal.h +51 -75
  141. data/src/core/ext/transport/chttp2/transport/parsing.cc +83 -109
  142. data/src/core/ext/transport/chttp2/transport/stream_lists.cc +2 -0
  143. data/src/core/ext/transport/chttp2/transport/stream_map.h +0 -8
  144. data/src/core/ext/transport/chttp2/transport/varint.h +0 -8
  145. data/src/core/ext/transport/chttp2/transport/writing.cc +61 -65
  146. data/src/core/ext/transport/inproc/inproc_plugin.cc +2 -4
  147. data/src/core/ext/transport/inproc/inproc_transport.cc +177 -188
  148. data/src/core/ext/transport/inproc/inproc_transport.h +0 -8
  149. data/src/core/lib/backoff/backoff.cc +39 -44
  150. data/src/core/lib/backoff/backoff.h +61 -57
  151. data/src/core/lib/channel/channel_args.cc +8 -10
  152. data/src/core/lib/channel/channel_args.h +4 -13
  153. data/src/core/lib/channel/channel_stack.cc +19 -27
  154. data/src/core/lib/channel/channel_stack.h +27 -47
  155. data/src/core/lib/channel/channel_stack_builder.cc +11 -14
  156. data/src/core/lib/channel/channel_stack_builder.h +4 -15
  157. data/src/core/lib/channel/connected_channel.cc +23 -36
  158. data/src/core/lib/channel/connected_channel.h +1 -10
  159. data/src/core/lib/channel/handshaker.cc +31 -40
  160. data/src/core/lib/channel/handshaker.h +14 -25
  161. data/src/core/lib/channel/handshaker_factory.cc +6 -6
  162. data/src/core/lib/channel/handshaker_factory.h +5 -15
  163. data/src/core/lib/channel/handshaker_registry.cc +9 -13
  164. data/src/core/lib/channel/handshaker_registry.h +2 -11
  165. data/src/core/lib/compression/algorithm_metadata.h +0 -8
  166. data/src/core/lib/compression/message_compress.cc +19 -23
  167. data/src/core/lib/compression/message_compress.h +2 -12
  168. data/src/core/lib/compression/stream_compression.cc +1 -1
  169. data/src/core/lib/compression/stream_compression.h +0 -8
  170. data/src/core/lib/compression/stream_compression_gzip.cc +12 -11
  171. data/src/core/lib/compression/stream_compression_gzip.h +0 -8
  172. data/src/core/lib/compression/stream_compression_identity.h +0 -8
  173. data/src/core/lib/debug/stats.cc +4 -4
  174. data/src/core/lib/debug/stats.h +9 -19
  175. data/src/core/lib/debug/stats_data.cc +85 -116
  176. data/src/core/lib/debug/stats_data.h +236 -312
  177. data/src/core/lib/debug/trace.cc +1 -1
  178. data/src/core/lib/debug/trace.h +0 -12
  179. data/src/core/lib/{support → gpr++}/abstract.h +8 -3
  180. data/src/core/lib/{support → gpr++}/atomic.h +5 -5
  181. data/src/core/lib/{support → gpr++}/atomic_with_atm.h +3 -3
  182. data/src/core/lib/{support → gpr++}/atomic_with_std.h +3 -3
  183. data/src/core/lib/gpr++/debug_location.h +52 -0
  184. data/src/core/lib/gpr++/inlined_vector.h +112 -0
  185. data/src/core/lib/{support → gpr++}/manual_constructor.h +2 -2
  186. data/src/core/lib/{support → gpr++}/memory.h +3 -3
  187. data/src/core/lib/gpr++/orphanable.h +171 -0
  188. data/src/core/lib/gpr++/ref_counted.h +133 -0
  189. data/src/core/lib/gpr++/ref_counted_ptr.h +99 -0
  190. data/src/core/lib/{support → gpr}/alloc.cc +0 -0
  191. data/src/core/lib/{support → gpr}/arena.cc +1 -1
  192. data/src/core/lib/{support → gpr}/arena.h +3 -11
  193. data/src/core/lib/{support → gpr}/atm.cc +0 -0
  194. data/src/core/lib/{support → gpr}/avl.cc +0 -0
  195. data/src/core/lib/{support → gpr}/cmdline.cc +1 -1
  196. data/src/core/lib/{support → gpr}/cpu_iphone.cc +0 -0
  197. data/src/core/lib/{support → gpr}/cpu_linux.cc +0 -0
  198. data/src/core/lib/{support → gpr}/cpu_posix.cc +0 -0
  199. data/src/core/lib/{support → gpr}/cpu_windows.cc +0 -0
  200. data/src/core/lib/{support → gpr}/env.h +3 -11
  201. data/src/core/lib/{support → gpr}/env_linux.cc +2 -2
  202. data/src/core/lib/{support → gpr}/env_posix.cc +4 -4
  203. data/src/core/lib/{support → gpr}/env_windows.cc +3 -3
  204. data/src/core/lib/{support → gpr}/fork.cc +3 -3
  205. data/src/core/lib/{support → gpr}/fork.h +3 -3
  206. data/src/core/lib/{support → gpr}/host_port.cc +1 -1
  207. data/src/core/lib/{support → gpr}/log.cc +3 -3
  208. data/src/core/lib/{support → gpr}/log_android.cc +3 -3
  209. data/src/core/lib/{support → gpr}/log_linux.cc +1 -1
  210. data/src/core/lib/{support → gpr}/log_posix.cc +5 -5
  211. data/src/core/lib/{support → gpr}/log_windows.cc +3 -3
  212. data/src/core/lib/{support → gpr}/mpscq.cc +1 -1
  213. data/src/core/lib/{support → gpr}/mpscq.h +3 -10
  214. data/src/core/lib/{support → gpr}/murmur_hash.cc +1 -1
  215. data/src/core/lib/{support → gpr}/murmur_hash.h +3 -11
  216. data/src/core/lib/{support → gpr}/spinlock.h +3 -3
  217. data/src/core/lib/{support → gpr}/string.cc +1 -1
  218. data/src/core/lib/{support → gpr}/string.h +3 -10
  219. data/src/core/lib/{support → gpr}/string_posix.cc +0 -0
  220. data/src/core/lib/{support → gpr}/string_util_windows.cc +2 -2
  221. data/src/core/lib/{support → gpr}/string_windows.cc +1 -1
  222. data/src/core/lib/{support → gpr}/string_windows.h +3 -11
  223. data/src/core/lib/{support → gpr}/subprocess_posix.cc +0 -0
  224. data/src/core/lib/{support → gpr}/subprocess_windows.cc +2 -2
  225. data/src/core/lib/{support → gpr}/sync.cc +0 -0
  226. data/src/core/lib/{support → gpr}/sync_posix.cc +10 -1
  227. data/src/core/lib/{support → gpr}/sync_windows.cc +0 -0
  228. data/src/core/lib/{support → gpr}/thd.cc +0 -0
  229. data/src/core/lib/{support → gpr}/thd_internal.h +3 -3
  230. data/src/core/lib/{support → gpr}/thd_posix.cc +18 -2
  231. data/src/core/lib/{support → gpr}/thd_windows.cc +2 -1
  232. data/src/core/lib/{support → gpr}/time.cc +0 -0
  233. data/src/core/lib/{support → gpr}/time_posix.cc +2 -4
  234. data/src/core/lib/{support → gpr}/time_precise.cc +1 -1
  235. data/src/core/lib/{support → gpr}/time_precise.h +3 -11
  236. data/src/core/lib/{support → gpr}/time_windows.cc +1 -3
  237. data/src/core/lib/{support → gpr}/tls_pthread.cc +0 -0
  238. data/src/core/lib/{support → gpr}/tmpfile.h +3 -11
  239. data/src/core/lib/{support → gpr}/tmpfile_msys.cc +2 -2
  240. data/src/core/lib/{support → gpr}/tmpfile_posix.cc +2 -2
  241. data/src/core/lib/{support → gpr}/tmpfile_windows.cc +2 -2
  242. data/src/core/lib/{support → gpr}/wrap_memcpy.cc +0 -0
  243. data/src/core/lib/http/format_request.cc +1 -1
  244. data/src/core/lib/http/format_request.h +0 -8
  245. data/src/core/lib/http/httpcli.cc +55 -74
  246. data/src/core/lib/http/httpcli.h +13 -22
  247. data/src/core/lib/http/httpcli_security_connector.cc +27 -33
  248. data/src/core/lib/http/parser.h +0 -8
  249. data/src/core/lib/iomgr/block_annotate.h +10 -17
  250. data/src/core/lib/iomgr/call_combiner.cc +14 -17
  251. data/src/core/lib/iomgr/call_combiner.h +16 -34
  252. data/src/core/lib/iomgr/closure.h +24 -37
  253. data/src/core/lib/iomgr/combiner.cc +62 -66
  254. data/src/core/lib/iomgr/combiner.h +6 -16
  255. data/src/core/lib/iomgr/endpoint.cc +15 -21
  256. data/src/core/lib/iomgr/endpoint.h +16 -33
  257. data/src/core/lib/iomgr/endpoint_pair.h +0 -8
  258. data/src/core/lib/iomgr/endpoint_pair_posix.cc +4 -5
  259. data/src/core/lib/iomgr/endpoint_pair_windows.cc +4 -6
  260. data/src/core/lib/iomgr/error.cc +2 -6
  261. data/src/core/lib/iomgr/error.h +4 -9
  262. data/src/core/lib/iomgr/error_internal.h +0 -8
  263. data/src/core/lib/iomgr/ev_epoll1_linux.cc +110 -117
  264. data/src/core/lib/iomgr/ev_epoll1_linux.h +0 -8
  265. data/src/core/lib/iomgr/ev_epollex_linux.cc +111 -141
  266. data/src/core/lib/iomgr/ev_epollex_linux.h +0 -8
  267. data/src/core/lib/iomgr/ev_epollsig_linux.cc +83 -109
  268. data/src/core/lib/iomgr/ev_epollsig_linux.h +2 -10
  269. data/src/core/lib/iomgr/ev_poll_posix.cc +103 -125
  270. data/src/core/lib/iomgr/ev_poll_posix.h +0 -8
  271. data/src/core/lib/iomgr/ev_posix.cc +35 -50
  272. data/src/core/lib/iomgr/ev_posix.h +27 -53
  273. data/src/core/lib/iomgr/exec_ctx.cc +46 -78
  274. data/src/core/lib/iomgr/exec_ctx.h +127 -60
  275. data/src/core/lib/iomgr/executor.cc +34 -38
  276. data/src/core/lib/iomgr/executor.h +3 -11
  277. data/src/core/lib/iomgr/fork_posix.cc +13 -12
  278. data/src/core/lib/iomgr/gethostname.h +0 -8
  279. data/src/core/lib/iomgr/gethostname_sysconf.cc +1 -1
  280. data/src/core/lib/iomgr/iocp_windows.cc +14 -16
  281. data/src/core/lib/iomgr/iocp_windows.h +1 -10
  282. data/src/core/lib/iomgr/iomgr.cc +60 -59
  283. data/src/core/lib/iomgr/iomgr.h +3 -12
  284. data/src/core/lib/iomgr/iomgr_internal.h +0 -8
  285. data/src/core/lib/iomgr/iomgr_uv.cc +2 -3
  286. data/src/core/lib/iomgr/iomgr_uv.h +0 -8
  287. data/src/core/lib/iomgr/is_epollexclusive_available.cc +1 -1
  288. data/src/core/lib/iomgr/load_file.cc +1 -1
  289. data/src/core/lib/iomgr/load_file.h +0 -8
  290. data/src/core/lib/iomgr/lockfree_event.cc +7 -8
  291. data/src/core/lib/iomgr/lockfree_event.h +3 -3
  292. data/src/core/lib/iomgr/polling_entity.cc +6 -10
  293. data/src/core/lib/iomgr/polling_entity.h +2 -11
  294. data/src/core/lib/iomgr/pollset.h +4 -13
  295. data/src/core/lib/iomgr/pollset_set.h +5 -18
  296. data/src/core/lib/iomgr/pollset_set_uv.cc +5 -10
  297. data/src/core/lib/iomgr/pollset_set_windows.cc +5 -10
  298. data/src/core/lib/iomgr/pollset_uv.cc +8 -9
  299. data/src/core/lib/iomgr/pollset_uv.h +0 -8
  300. data/src/core/lib/iomgr/pollset_windows.cc +14 -15
  301. data/src/core/lib/iomgr/pollset_windows.h +0 -8
  302. data/src/core/lib/iomgr/port.h +6 -1
  303. data/src/core/lib/iomgr/resolve_address.h +1 -10
  304. data/src/core/lib/iomgr/resolve_address_posix.cc +10 -12
  305. data/src/core/lib/iomgr/resolve_address_uv.cc +7 -8
  306. data/src/core/lib/iomgr/resolve_address_windows.cc +8 -9
  307. data/src/core/lib/iomgr/resource_quota.cc +77 -107
  308. data/src/core/lib/iomgr/resource_quota.h +8 -25
  309. data/src/core/lib/iomgr/sockaddr_utils.cc +1 -1
  310. data/src/core/lib/iomgr/sockaddr_utils.h +0 -8
  311. data/src/core/lib/iomgr/socket_factory_posix.cc +1 -1
  312. data/src/core/lib/iomgr/socket_factory_posix.h +0 -8
  313. data/src/core/lib/iomgr/socket_mutator.cc +1 -1
  314. data/src/core/lib/iomgr/socket_mutator.h +1 -9
  315. data/src/core/lib/iomgr/socket_utils.h +0 -8
  316. data/src/core/lib/iomgr/socket_utils_common_posix.cc +1 -1
  317. data/src/core/lib/iomgr/socket_utils_posix.h +0 -8
  318. data/src/core/lib/iomgr/socket_windows.cc +8 -11
  319. data/src/core/lib/iomgr/socket_windows.h +3 -14
  320. data/src/core/lib/iomgr/tcp_client.h +1 -10
  321. data/src/core/lib/iomgr/tcp_client_posix.cc +94 -78
  322. data/src/core/lib/iomgr/tcp_client_posix.h +36 -8
  323. data/src/core/lib/iomgr/tcp_client_uv.cc +16 -23
  324. data/src/core/lib/iomgr/tcp_client_windows.cc +22 -25
  325. data/src/core/lib/iomgr/tcp_posix.cc +131 -153
  326. data/src/core/lib/iomgr/tcp_posix.h +3 -12
  327. data/src/core/lib/iomgr/tcp_server.h +6 -17
  328. data/src/core/lib/iomgr/tcp_server_posix.cc +31 -35
  329. data/src/core/lib/iomgr/tcp_server_utils_posix.h +0 -8
  330. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +1 -1
  331. data/src/core/lib/iomgr/tcp_server_uv.cc +23 -34
  332. data/src/core/lib/iomgr/tcp_server_windows.cc +24 -34
  333. data/src/core/lib/iomgr/tcp_uv.cc +42 -56
  334. data/src/core/lib/iomgr/tcp_uv.h +0 -8
  335. data/src/core/lib/iomgr/tcp_windows.cc +43 -50
  336. data/src/core/lib/iomgr/tcp_windows.h +1 -9
  337. data/src/core/lib/iomgr/time_averaged_stats.h +0 -8
  338. data/src/core/lib/iomgr/timer.h +6 -15
  339. data/src/core/lib/iomgr/timer_generic.cc +22 -27
  340. data/src/core/lib/iomgr/timer_heap.h +0 -8
  341. data/src/core/lib/iomgr/timer_manager.cc +17 -19
  342. data/src/core/lib/iomgr/timer_manager.h +0 -8
  343. data/src/core/lib/iomgr/timer_uv.cc +12 -14
  344. data/src/core/lib/iomgr/udp_server.cc +148 -54
  345. data/src/core/lib/iomgr/udp_server.h +16 -21
  346. data/src/core/lib/iomgr/unix_sockets_posix.h +0 -8
  347. data/src/core/lib/iomgr/wakeup_fd_cv.cc +4 -4
  348. data/src/core/lib/iomgr/wakeup_fd_cv.h +12 -20
  349. data/src/core/lib/iomgr/wakeup_fd_nospecial.cc +1 -1
  350. data/src/core/lib/iomgr/wakeup_fd_pipe.h +0 -8
  351. data/src/core/lib/iomgr/wakeup_fd_posix.h +0 -8
  352. data/src/core/lib/json/json.h +0 -8
  353. data/src/core/lib/json/json_reader.h +0 -8
  354. data/src/core/lib/json/json_writer.h +0 -8
  355. data/src/core/lib/profiling/basic_timers.cc +3 -2
  356. data/src/core/lib/profiling/timers.h +0 -8
  357. data/src/core/lib/security/context/security_context.cc +9 -10
  358. data/src/core/lib/security/context/security_context.h +0 -8
  359. data/src/core/lib/security/credentials/composite/composite_credentials.cc +23 -28
  360. data/src/core/lib/security/credentials/composite/composite_credentials.h +0 -8
  361. data/src/core/lib/security/credentials/credentials.cc +33 -42
  362. data/src/core/lib/security/credentials/credentials.h +24 -43
  363. data/src/core/lib/security/credentials/credentials_metadata.cc +2 -2
  364. data/src/core/lib/security/credentials/fake/fake_credentials.cc +16 -22
  365. data/src/core/lib/security/credentials/fake/fake_credentials.h +0 -8
  366. data/src/core/lib/security/credentials/google_default/credentials_generic.cc +3 -3
  367. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +28 -34
  368. data/src/core/lib/security/credentials/google_default/google_default_credentials.h +0 -8
  369. data/src/core/lib/security/credentials/iam/iam_credentials.cc +9 -13
  370. data/src/core/lib/security/credentials/jwt/json_token.cc +1 -1
  371. data/src/core/lib/security/credentials/jwt/json_token.h +0 -8
  372. data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +14 -20
  373. data/src/core/lib/security/credentials/jwt/jwt_credentials.h +1 -10
  374. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +56 -72
  375. data/src/core/lib/security/credentials/jwt/jwt_verifier.h +5 -17
  376. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +47 -55
  377. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +3 -12
  378. data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +23 -28
  379. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +8 -13
  380. data/src/core/lib/security/credentials/ssl/ssl_credentials.h +0 -8
  381. data/src/core/lib/security/transport/auth_filters.h +0 -8
  382. data/src/core/lib/security/transport/client_auth_filter.cc +45 -54
  383. data/src/core/lib/security/transport/lb_targets_info.cc +2 -2
  384. data/src/core/lib/security/transport/lb_targets_info.h +0 -8
  385. data/src/core/lib/security/transport/secure_endpoint.cc +54 -68
  386. data/src/core/lib/security/transport/secure_endpoint.h +0 -8
  387. data/src/core/lib/security/transport/security_connector.cc +62 -86
  388. data/src/core/lib/security/transport/security_connector.h +22 -39
  389. data/src/core/lib/security/transport/security_handshaker.cc +83 -106
  390. data/src/core/lib/security/transport/security_handshaker.h +1 -10
  391. data/src/core/lib/security/transport/server_auth_filter.cc +31 -38
  392. data/src/core/lib/security/transport/tsi_error.h +0 -8
  393. data/src/core/lib/security/util/json_util.h +0 -8
  394. data/src/core/lib/slice/b64.cc +5 -6
  395. data/src/core/lib/slice/b64.h +3 -12
  396. data/src/core/lib/slice/percent_encoding.h +0 -8
  397. data/src/core/lib/slice/slice.cc +8 -9
  398. data/src/core/lib/slice/slice_buffer.cc +11 -16
  399. data/src/core/lib/slice/slice_hash_table.cc +5 -7
  400. data/src/core/lib/slice/slice_hash_table.h +2 -12
  401. data/src/core/lib/slice/slice_intern.cc +4 -5
  402. data/src/core/lib/slice/slice_internal.h +4 -15
  403. data/src/core/lib/slice/slice_string_helpers.cc +1 -1
  404. data/src/core/lib/slice/slice_string_helpers.h +1 -9
  405. data/src/core/lib/surface/alarm.cc +11 -14
  406. data/src/core/lib/surface/alarm_internal.h +0 -8
  407. data/src/core/lib/surface/byte_buffer.cc +2 -3
  408. data/src/core/lib/surface/byte_buffer_reader.cc +7 -9
  409. data/src/core/lib/surface/call.cc +198 -241
  410. data/src/core/lib/surface/call.h +9 -23
  411. data/src/core/lib/surface/call_details.cc +3 -4
  412. data/src/core/lib/surface/call_log_batch.cc +1 -1
  413. data/src/core/lib/surface/call_test_only.h +0 -8
  414. data/src/core/lib/surface/channel.cc +53 -64
  415. data/src/core/lib/surface/channel.h +12 -23
  416. data/src/core/lib/surface/channel_init.cc +2 -3
  417. data/src/core/lib/surface/channel_init.h +2 -12
  418. data/src/core/lib/surface/channel_ping.cc +7 -9
  419. data/src/core/lib/surface/channel_stack_type.h +0 -8
  420. data/src/core/lib/surface/completion_queue.cc +158 -176
  421. data/src/core/lib/surface/completion_queue.h +9 -20
  422. data/src/core/lib/surface/completion_queue_factory.h +0 -8
  423. data/src/core/lib/surface/event_string.cc +1 -1
  424. data/src/core/lib/surface/event_string.h +0 -8
  425. data/src/core/lib/surface/init.cc +27 -25
  426. data/src/core/lib/surface/init.h +0 -8
  427. data/src/core/lib/surface/init_secure.cc +2 -2
  428. data/src/core/lib/surface/lame_client.cc +30 -33
  429. data/src/core/lib/surface/lame_client.h +0 -8
  430. data/src/core/lib/surface/server.cc +151 -203
  431. data/src/core/lib/surface/server.h +7 -16
  432. data/src/core/lib/surface/validate_metadata.h +0 -8
  433. data/src/core/lib/surface/version.cc +2 -2
  434. data/src/core/lib/transport/bdp_estimator.cc +2 -2
  435. data/src/core/lib/transport/bdp_estimator.h +1 -1
  436. data/src/core/lib/transport/byte_stream.cc +24 -38
  437. data/src/core/lib/transport/byte_stream.h +10 -25
  438. data/src/core/lib/transport/connectivity_state.cc +9 -13
  439. data/src/core/lib/transport/connectivity_state.h +4 -14
  440. data/src/core/lib/transport/error_utils.cc +6 -6
  441. data/src/core/lib/transport/error_utils.h +2 -11
  442. data/src/core/lib/transport/metadata.cc +21 -23
  443. data/src/core/lib/transport/metadata.h +8 -20
  444. data/src/core/lib/transport/metadata_batch.cc +34 -45
  445. data/src/core/lib/transport/metadata_batch.h +18 -32
  446. data/src/core/lib/transport/service_config.cc +11 -15
  447. data/src/core/lib/transport/service_config.h +3 -13
  448. data/src/core/lib/transport/static_metadata.cc +1 -1
  449. data/src/core/lib/transport/static_metadata.h +1 -7
  450. data/src/core/lib/transport/status_conversion.cc +2 -3
  451. data/src/core/lib/transport/status_conversion.h +1 -10
  452. data/src/core/lib/transport/timeout_encoding.cc +1 -1
  453. data/src/core/lib/transport/timeout_encoding.h +1 -9
  454. data/src/core/lib/transport/transport.cc +36 -50
  455. data/src/core/lib/transport/transport.h +28 -30
  456. data/src/core/lib/transport/transport_impl.h +12 -23
  457. data/src/core/lib/transport/transport_op_string.cc +2 -2
  458. data/src/core/plugin_registry/grpc_plugin_registry.cc +34 -34
  459. data/src/core/tsi/fake_transport_security.cc +7 -10
  460. data/src/core/tsi/fake_transport_security.h +0 -8
  461. data/src/core/tsi/gts_transport_security.cc +2 -2
  462. data/src/core/tsi/gts_transport_security.h +0 -8
  463. data/src/core/tsi/ssl_transport_security.cc +3 -0
  464. data/src/core/tsi/ssl_transport_security.h +0 -8
  465. data/src/core/tsi/ssl_types.h +0 -8
  466. data/src/core/tsi/transport_security.h +1 -9
  467. data/src/core/tsi/transport_security_adapter.h +0 -8
  468. data/src/core/tsi/transport_security_grpc.cc +11 -18
  469. data/src/core/tsi/transport_security_grpc.h +9 -21
  470. data/src/core/tsi/transport_security_interface.h +0 -8
  471. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +0 -30
  472. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +2 -48
  473. data/src/ruby/lib/grpc/version.rb +1 -1
  474. data/src/ruby/spec/channel_connection_spec.rb +2 -1
  475. data/src/ruby/spec/client_auth_spec.rb +1 -1
  476. data/src/ruby/spec/client_server_spec.rb +2 -2
  477. data/src/ruby/spec/generic/active_call_spec.rb +1 -1
  478. data/src/ruby/spec/generic/client_stub_spec.rb +4 -4
  479. data/src/ruby/spec/generic/interceptor_registry_spec.rb +1 -1
  480. data/src/ruby/spec/generic/rpc_server_spec.rb +12 -12
  481. data/src/ruby/spec/google_rpc_status_utils_spec.rb +3 -2
  482. data/src/ruby/spec/pb/health/checker_spec.rb +1 -1
  483. data/src/ruby/spec/server_spec.rb +9 -9
  484. data/src/ruby/spec/support/helpers.rb +35 -1
  485. metadata +68 -66
  486. data/include/grpc/impl/codegen/exec_ctx_fwd.h +0 -26
  487. data/include/grpc/support/histogram.h +0 -64
  488. data/src/core/lib/support/histogram.cc +0 -227
@@ -21,13 +21,11 @@
21
21
 
22
22
  #include <grpc/support/atm.h>
23
23
  #include <grpc/support/cpu.h>
24
+ #include <grpc/support/log.h>
25
+ #include <grpc/support/tls.h>
24
26
 
25
27
  #include "src/core/lib/iomgr/closure.h"
26
28
 
27
- #ifdef __cplusplus
28
- extern "C" {
29
- #endif
30
-
31
29
  typedef gpr_atm grpc_millis;
32
30
 
33
31
  #define GRPC_MILLIS_INF_FUTURE GPR_ATM_MAX
@@ -45,6 +43,13 @@ typedef struct grpc_combiner grpc_combiner;
45
43
  should be given to not delete said call/channel from this exec_ctx */
46
44
  #define GRPC_EXEC_CTX_FLAG_THREAD_RESOURCE_LOOP 2
47
45
 
46
+ extern grpc_closure_scheduler* grpc_schedule_on_exec_ctx;
47
+
48
+ gpr_timespec grpc_millis_to_timespec(grpc_millis millis, gpr_clock_type clock);
49
+ grpc_millis grpc_timespec_to_millis_round_down(gpr_timespec timespec);
50
+ grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec timespec);
51
+
52
+ namespace grpc_core {
48
53
  /** Execution context.
49
54
  * A bag of data that collects information along a callstack.
50
55
  * Generally created at public API entry points, and passed down as
@@ -65,67 +70,129 @@ typedef struct grpc_combiner grpc_combiner;
65
70
  * - Instances are always passed as the first argument to a function that
66
71
  * takes it, and always as a pointer (grpc_exec_ctx is never copied).
67
72
  */
68
- struct grpc_exec_ctx {
69
- grpc_closure_list closure_list;
70
- /** currently active combiner: updated only via combiner.c */
71
- grpc_combiner* active_combiner;
72
- /** last active combiner in the active combiner list */
73
- grpc_combiner* last_combiner;
74
- uintptr_t flags;
75
- unsigned starting_cpu;
76
- void* check_ready_to_finish_arg;
77
- bool (*check_ready_to_finish)(grpc_exec_ctx* exec_ctx, void* arg);
78
-
79
- bool now_is_valid;
80
- grpc_millis now;
81
- };
73
+ class ExecCtx {
74
+ public:
75
+ /** Default Constructor */
76
+
77
+ ExecCtx() : flags_(GRPC_EXEC_CTX_FLAG_IS_FINISHED) { Set(this); }
78
+
79
+ /** Parameterised Constructor */
80
+ ExecCtx(uintptr_t fl) : flags_(fl) { Set(this); }
82
81
 
83
- /* initializer for grpc_exec_ctx:
84
- prefer to use GRPC_EXEC_CTX_INIT whenever possible */
85
- #define GRPC_EXEC_CTX_INITIALIZER(flags, finish_check, finish_check_arg) \
86
- { \
87
- GRPC_CLOSURE_LIST_INIT, NULL, NULL, flags, gpr_cpu_current_cpu(), \
88
- finish_check_arg, finish_check, false, 0 \
82
+ /** Destructor */
83
+ virtual ~ExecCtx() {
84
+ flags_ |= GRPC_EXEC_CTX_FLAG_IS_FINISHED;
85
+ Flush();
86
+ Set(last_exec_ctx_);
89
87
  }
90
88
 
91
- /* initialize an execution context at the top level of an API call into grpc
92
- (this is safe to use elsewhere, though possibly not as efficient) */
93
- #define GRPC_EXEC_CTX_INIT \
94
- GRPC_EXEC_CTX_INITIALIZER(GRPC_EXEC_CTX_FLAG_IS_FINISHED, NULL, NULL)
89
+ /** Disallow copy and assignment operators */
90
+ ExecCtx(const ExecCtx&) = delete;
91
+ ExecCtx& operator=(const ExecCtx&) = delete;
95
92
 
96
- extern grpc_closure_scheduler* grpc_schedule_on_exec_ctx;
93
+ /** Return starting_cpu */
94
+ unsigned starting_cpu() const { return starting_cpu_; }
97
95
 
98
- bool grpc_exec_ctx_has_work(grpc_exec_ctx* exec_ctx);
99
-
100
- /** Flush any work that has been enqueued onto this grpc_exec_ctx.
101
- * Caller must guarantee that no interfering locks are held.
102
- * Returns true if work was performed, false otherwise. */
103
- bool grpc_exec_ctx_flush(grpc_exec_ctx* exec_ctx);
104
- /** Finish any pending work for a grpc_exec_ctx. Must be called before
105
- * the instance is destroyed, or work may be lost. */
106
- void grpc_exec_ctx_finish(grpc_exec_ctx* exec_ctx);
107
- /** Returns true if we'd like to leave this execution context as soon as
108
- possible: useful for deciding whether to do something more or not depending
109
- on outside context */
110
- bool grpc_exec_ctx_ready_to_finish(grpc_exec_ctx* exec_ctx);
111
- /** A finish check that is never ready to finish */
112
- bool grpc_never_ready_to_finish(grpc_exec_ctx* exec_ctx, void* arg_ignored);
113
- /** A finish check that is always ready to finish */
114
- bool grpc_always_ready_to_finish(grpc_exec_ctx* exec_ctx, void* arg_ignored);
115
-
116
- void grpc_exec_ctx_global_init(void);
117
-
118
- void grpc_exec_ctx_global_init(void);
119
- void grpc_exec_ctx_global_shutdown(void);
120
-
121
- grpc_millis grpc_exec_ctx_now(grpc_exec_ctx* exec_ctx);
122
- void grpc_exec_ctx_invalidate_now(grpc_exec_ctx* exec_ctx);
123
- gpr_timespec grpc_millis_to_timespec(grpc_millis millis, gpr_clock_type clock);
124
- grpc_millis grpc_timespec_to_millis_round_down(gpr_timespec timespec);
125
- grpc_millis grpc_timespec_to_millis_round_up(gpr_timespec timespec);
96
+ struct CombinerData {
97
+ /* currently active combiner: updated only via combiner.c */
98
+ grpc_combiner* active_combiner;
99
+ /* last active combiner in the active combiner list */
100
+ grpc_combiner* last_combiner;
101
+ };
102
+
103
+ /** Only to be used by grpc-combiner code */
104
+ CombinerData* combiner_data() { return &combiner_data_; }
105
+
106
+ /** Return pointer to grpc_closure_list */
107
+ grpc_closure_list* closure_list() { return &closure_list_; }
108
+
109
+ /** Return flags */
110
+ uintptr_t flags() { return flags_; }
111
+
112
+ /** Checks if there is work to be done */
113
+ bool HasWork() {
114
+ return combiner_data_.active_combiner != nullptr ||
115
+ !grpc_closure_list_empty(closure_list_);
116
+ }
126
117
 
127
- #ifdef __cplusplus
128
- }
129
- #endif
118
+ /** Flush any work that has been enqueued onto this grpc_exec_ctx.
119
+ * Caller must guarantee that no interfering locks are held.
120
+ * Returns true if work was performed, false otherwise. */
121
+ bool Flush();
122
+
123
+ /** Returns true if we'd like to leave this execution context as soon as
124
+ possible: useful for deciding whether to do something more or not depending
125
+ on outside context */
126
+ bool IsReadyToFinish() {
127
+ if ((flags_ & GRPC_EXEC_CTX_FLAG_IS_FINISHED) == 0) {
128
+ if (CheckReadyToFinish()) {
129
+ flags_ |= GRPC_EXEC_CTX_FLAG_IS_FINISHED;
130
+ return true;
131
+ }
132
+ return false;
133
+ } else {
134
+ return true;
135
+ }
136
+ }
137
+
138
+ /** Returns the stored current time relative to start if valid,
139
+ * otherwise refreshes the stored time, sets it valid and returns the new
140
+ * value */
141
+ grpc_millis Now();
142
+
143
+ /** Invalidates the stored time value. A new time value will be set on calling
144
+ * Now() */
145
+ void InvalidateNow() { now_is_valid_ = false; }
146
+
147
+ /** To be used only by shutdown code in iomgr */
148
+ void SetNowIomgrShutdown() {
149
+ now_ = GRPC_MILLIS_INF_FUTURE;
150
+ now_is_valid_ = true;
151
+ }
152
+
153
+ /** To be used only for testing.
154
+ * Sets the now value
155
+ */
156
+ void TestOnlySetNow(grpc_millis new_val) {
157
+ now_ = new_val;
158
+ now_is_valid_ = true;
159
+ }
160
+
161
+ /** Global initialization for ExecCtx. Called by iomgr */
162
+ static void GlobalInit(void);
163
+
164
+ /** Global shutdown for ExecCtx. Called by iomgr */
165
+ static void GlobalShutdown(void) { gpr_tls_destroy(&exec_ctx_); }
166
+
167
+ /** Gets pointer to current exec_ctx */
168
+ static ExecCtx* Get() {
169
+ return reinterpret_cast<ExecCtx*>(gpr_tls_get(&exec_ctx_));
170
+ }
171
+
172
+ protected:
173
+ /** Check if ready to finish */
174
+ virtual bool CheckReadyToFinish() { return false; }
175
+
176
+ /** Disallow delete on ExecCtx */
177
+ static void operator delete(void* p) { abort(); }
178
+
179
+ private:
180
+ /** Set exec_ctx_ to exec_ctx */
181
+ void Set(ExecCtx* exec_ctx) {
182
+ gpr_tls_set(&exec_ctx_, reinterpret_cast<intptr_t>(exec_ctx));
183
+ }
184
+
185
+ grpc_closure_list closure_list_ = GRPC_CLOSURE_LIST_INIT;
186
+ CombinerData combiner_data_ = {nullptr, nullptr};
187
+ uintptr_t flags_;
188
+ unsigned starting_cpu_ = gpr_cpu_current_cpu();
189
+
190
+ bool now_is_valid_ = false;
191
+ grpc_millis now_ = 0;
192
+
193
+ GPR_TLS_CLASS_DECL(exec_ctx_);
194
+ ExecCtx* last_exec_ctx_ = Get();
195
+ };
196
+ } // namespace grpc_core
130
197
 
131
198
  #endif /* GRPC_CORE_LIB_IOMGR_EXEC_CTX_H */
@@ -29,8 +29,8 @@
29
29
  #include <grpc/support/useful.h>
30
30
 
31
31
  #include "src/core/lib/debug/stats.h"
32
+ #include "src/core/lib/gpr/spinlock.h"
32
33
  #include "src/core/lib/iomgr/exec_ctx.h"
33
- #include "src/core/lib/support/spinlock.h"
34
34
 
35
35
  #define MAX_DEPTH 2
36
36
 
@@ -55,7 +55,7 @@ grpc_core::TraceFlag executor_trace(false, "executor");
55
55
 
56
56
  static void executor_thread(void* arg);
57
57
 
58
- static size_t run_closures(grpc_exec_ctx* exec_ctx, grpc_closure_list list) {
58
+ static size_t run_closures(grpc_closure_list list) {
59
59
  size_t n = 0;
60
60
 
61
61
  grpc_closure* c = list.head;
@@ -73,11 +73,11 @@ static size_t run_closures(grpc_exec_ctx* exec_ctx, grpc_closure_list list) {
73
73
  #ifndef NDEBUG
74
74
  c->scheduled = false;
75
75
  #endif
76
- c->cb(exec_ctx, c->cb_arg, error);
76
+ c->cb(c->cb_arg, error);
77
77
  GRPC_ERROR_UNREF(error);
78
78
  c = next;
79
79
  n++;
80
- grpc_exec_ctx_flush(exec_ctx);
80
+ grpc_core::ExecCtx::Get()->Flush();
81
81
  }
82
82
 
83
83
  return n;
@@ -87,7 +87,7 @@ bool grpc_executor_is_threaded() {
87
87
  return gpr_atm_no_barrier_load(&g_cur_threads) > 0;
88
88
  }
89
89
 
90
- void grpc_executor_set_threading(grpc_exec_ctx* exec_ctx, bool threading) {
90
+ void grpc_executor_set_threading(bool threading) {
91
91
  gpr_atm cur_threads = gpr_atm_no_barrier_load(&g_cur_threads);
92
92
  if (threading) {
93
93
  if (cur_threads > 0) return;
@@ -104,8 +104,8 @@ void grpc_executor_set_threading(grpc_exec_ctx* exec_ctx, bool threading) {
104
104
 
105
105
  gpr_thd_options opt = gpr_thd_options_default();
106
106
  gpr_thd_options_set_joinable(&opt);
107
- gpr_thd_new(&g_thread_state[0].id, executor_thread, &g_thread_state[0],
108
- &opt);
107
+ gpr_thd_new(&g_thread_state[0].id, "grpc_executor", executor_thread,
108
+ &g_thread_state[0], &opt);
109
109
  } else {
110
110
  if (cur_threads == 0) return;
111
111
  for (size_t i = 0; i < g_max_threads; i++) {
@@ -125,28 +125,25 @@ void grpc_executor_set_threading(grpc_exec_ctx* exec_ctx, bool threading) {
125
125
  for (size_t i = 0; i < g_max_threads; i++) {
126
126
  gpr_mu_destroy(&g_thread_state[i].mu);
127
127
  gpr_cv_destroy(&g_thread_state[i].cv);
128
- run_closures(exec_ctx, g_thread_state[i].elems);
128
+ run_closures(g_thread_state[i].elems);
129
129
  }
130
130
  gpr_free(g_thread_state);
131
131
  gpr_tls_destroy(&g_this_thread_state);
132
132
  }
133
133
  }
134
134
 
135
- void grpc_executor_init(grpc_exec_ctx* exec_ctx) {
135
+ void grpc_executor_init() {
136
136
  gpr_atm_no_barrier_store(&g_cur_threads, 0);
137
- grpc_executor_set_threading(exec_ctx, true);
137
+ grpc_executor_set_threading(true);
138
138
  }
139
139
 
140
- void grpc_executor_shutdown(grpc_exec_ctx* exec_ctx) {
141
- grpc_executor_set_threading(exec_ctx, false);
142
- }
140
+ void grpc_executor_shutdown() { grpc_executor_set_threading(false); }
143
141
 
144
142
  static void executor_thread(void* arg) {
145
143
  thread_state* ts = (thread_state*)arg;
146
144
  gpr_tls_set(&g_this_thread_state, (intptr_t)ts);
147
145
 
148
- grpc_exec_ctx exec_ctx =
149
- GRPC_EXEC_CTX_INITIALIZER(0, grpc_never_ready_to_finish, nullptr);
146
+ grpc_core::ExecCtx exec_ctx(0);
150
147
 
151
148
  size_t subtract_depth = 0;
152
149
  for (;;) {
@@ -158,7 +155,7 @@ static void executor_thread(void* arg) {
158
155
  ts->depth -= subtract_depth;
159
156
  while (grpc_closure_list_empty(ts->elems) && !ts->shutdown) {
160
157
  ts->queued_long_job = false;
161
- gpr_cv_wait(&ts->cv, &ts->mu, gpr_inf_future(GPR_CLOCK_REALTIME));
158
+ gpr_cv_wait(&ts->cv, &ts->mu, gpr_inf_future(GPR_CLOCK_MONOTONIC));
162
159
  }
163
160
  if (ts->shutdown) {
164
161
  if (executor_trace.enabled()) {
@@ -168,7 +165,7 @@ static void executor_thread(void* arg) {
168
165
  gpr_mu_unlock(&ts->mu);
169
166
  break;
170
167
  }
171
- GRPC_STATS_INC_EXECUTOR_QUEUE_DRAINED(&exec_ctx);
168
+ GRPC_STATS_INC_EXECUTOR_QUEUE_DRAINED();
172
169
  grpc_closure_list exec = ts->elems;
173
170
  ts->elems = GRPC_CLOSURE_LIST_INIT;
174
171
  gpr_mu_unlock(&ts->mu);
@@ -176,19 +173,18 @@ static void executor_thread(void* arg) {
176
173
  gpr_log(GPR_DEBUG, "EXECUTOR[%d]: execute", (int)(ts - g_thread_state));
177
174
  }
178
175
 
179
- grpc_exec_ctx_invalidate_now(&exec_ctx);
180
- subtract_depth = run_closures(&exec_ctx, exec);
176
+ grpc_core::ExecCtx::Get()->InvalidateNow();
177
+ subtract_depth = run_closures(exec);
181
178
  }
182
- grpc_exec_ctx_finish(&exec_ctx);
183
179
  }
184
180
 
185
- static void executor_push(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
186
- grpc_error* error, bool is_short) {
181
+ static void executor_push(grpc_closure* closure, grpc_error* error,
182
+ bool is_short) {
187
183
  bool retry_push;
188
184
  if (is_short) {
189
- GRPC_STATS_INC_EXECUTOR_SCHEDULED_SHORT_ITEMS(exec_ctx);
185
+ GRPC_STATS_INC_EXECUTOR_SCHEDULED_SHORT_ITEMS();
190
186
  } else {
191
- GRPC_STATS_INC_EXECUTOR_SCHEDULED_LONG_ITEMS(exec_ctx);
187
+ GRPC_STATS_INC_EXECUTOR_SCHEDULED_LONG_ITEMS();
192
188
  }
193
189
  do {
194
190
  retry_push = false;
@@ -202,14 +198,16 @@ static void executor_push(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
202
198
  gpr_log(GPR_DEBUG, "EXECUTOR: schedule %p inline", closure);
203
199
  #endif
204
200
  }
205
- grpc_closure_list_append(&exec_ctx->closure_list, closure, error);
201
+ grpc_closure_list_append(grpc_core::ExecCtx::Get()->closure_list(),
202
+ closure, error);
206
203
  return;
207
204
  }
208
205
  thread_state* ts = (thread_state*)gpr_tls_get(&g_this_thread_state);
209
206
  if (ts == nullptr) {
210
- ts = &g_thread_state[GPR_HASH_POINTER(exec_ctx, cur_thread_count)];
207
+ ts = &g_thread_state[GPR_HASH_POINTER(grpc_core::ExecCtx::Get(),
208
+ cur_thread_count)];
211
209
  } else {
212
- GRPC_STATS_INC_EXECUTOR_SCHEDULED_TO_SELF(exec_ctx);
210
+ GRPC_STATS_INC_EXECUTOR_SCHEDULED_TO_SELF();
213
211
  }
214
212
  thread_state* orig_ts = ts;
215
213
 
@@ -244,8 +242,8 @@ static void executor_push(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
244
242
  }
245
243
  continue;
246
244
  }
247
- if (grpc_closure_list_empty(ts->elems)) {
248
- GRPC_STATS_INC_EXECUTOR_WAKEUP_INITIATED(exec_ctx);
245
+ if (grpc_closure_list_empty(ts->elems) && !ts->shutdown) {
246
+ GRPC_STATS_INC_EXECUTOR_WAKEUP_INITIATED();
249
247
  gpr_cv_signal(&ts->cv);
250
248
  }
251
249
  grpc_closure_list_append(&ts->elems, closure, error);
@@ -263,25 +261,23 @@ static void executor_push(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
263
261
 
264
262
  gpr_thd_options opt = gpr_thd_options_default();
265
263
  gpr_thd_options_set_joinable(&opt);
266
- gpr_thd_new(&g_thread_state[cur_thread_count].id, executor_thread,
267
- &g_thread_state[cur_thread_count], &opt);
264
+ gpr_thd_new(&g_thread_state[cur_thread_count].id, "gpr_executor",
265
+ executor_thread, &g_thread_state[cur_thread_count], &opt);
268
266
  }
269
267
  gpr_spinlock_unlock(&g_adding_thread_lock);
270
268
  }
271
269
  if (retry_push) {
272
- GRPC_STATS_INC_EXECUTOR_PUSH_RETRIES(exec_ctx);
270
+ GRPC_STATS_INC_EXECUTOR_PUSH_RETRIES();
273
271
  }
274
272
  } while (retry_push);
275
273
  }
276
274
 
277
- static void executor_push_short(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
278
- grpc_error* error) {
279
- executor_push(exec_ctx, closure, error, true);
275
+ static void executor_push_short(grpc_closure* closure, grpc_error* error) {
276
+ executor_push(closure, error, true);
280
277
  }
281
278
 
282
- static void executor_push_long(grpc_exec_ctx* exec_ctx, grpc_closure* closure,
283
- grpc_error* error) {
284
- executor_push(exec_ctx, closure, error, false);
279
+ static void executor_push_long(grpc_closure* closure, grpc_error* error) {
280
+ executor_push(closure, error, false);
285
281
  }
286
282
 
287
283
  static const grpc_closure_scheduler_vtable executor_vtable_short = {
@@ -21,10 +21,6 @@
21
21
 
22
22
  #include "src/core/lib/iomgr/closure.h"
23
23
 
24
- #ifdef __cplusplus
25
- extern "C" {
26
- #endif
27
-
28
24
  typedef enum {
29
25
  GRPC_EXECUTOR_SHORT,
30
26
  GRPC_EXECUTOR_LONG
@@ -35,22 +31,18 @@ typedef enum {
35
31
  * This mechanism is meant to outsource work (grpc_closure instances) to a
36
32
  * thread, for those cases where blocking isn't an option but there isn't a
37
33
  * non-blocking solution available. */
38
- void grpc_executor_init(grpc_exec_ctx* exec_ctx);
34
+ void grpc_executor_init();
39
35
 
40
36
  grpc_closure_scheduler* grpc_executor_scheduler(grpc_executor_job_length);
41
37
 
42
38
  /** Shutdown the executor, running all pending work as part of the call */
43
- void grpc_executor_shutdown(grpc_exec_ctx* exec_ctx);
39
+ void grpc_executor_shutdown();
44
40
 
45
41
  /** Is the executor multi-threaded? */
46
42
  bool grpc_executor_is_threaded();
47
43
 
48
44
  /* enable/disable threading - must be called after grpc_executor_init and before
49
45
  grpc_executor_shutdown */
50
- void grpc_executor_set_threading(grpc_exec_ctx* exec_ctx, bool enable);
51
-
52
- #ifdef __cplusplus
53
- }
54
- #endif
46
+ void grpc_executor_set_threading(bool enable);
55
47
 
56
48
  #endif /* GRPC_CORE_LIB_IOMGR_EXECUTOR_H */
@@ -27,13 +27,13 @@
27
27
  #include <grpc/support/thd.h>
28
28
  #include <grpc/support/useful.h>
29
29
 
30
+ #include "src/core/lib/gpr/env.h"
31
+ #include "src/core/lib/gpr/fork.h"
32
+ #include "src/core/lib/gpr/thd_internal.h"
30
33
  #include "src/core/lib/iomgr/ev_posix.h"
31
34
  #include "src/core/lib/iomgr/executor.h"
32
35
  #include "src/core/lib/iomgr/timer_manager.h"
33
36
  #include "src/core/lib/iomgr/wakeup_fd_posix.h"
34
- #include "src/core/lib/support/env.h"
35
- #include "src/core/lib/support/fork.h"
36
- #include "src/core/lib/support/thd_internal.h"
37
37
  #include "src/core/lib/surface/init.h"
38
38
 
39
39
  /*
@@ -49,10 +49,10 @@ void grpc_prefork() {
49
49
  return;
50
50
  }
51
51
  if (grpc_is_initialized()) {
52
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
52
+ grpc_core::ExecCtx exec_ctx;
53
53
  grpc_timer_manager_set_threading(false);
54
- grpc_executor_set_threading(&exec_ctx, false);
55
- grpc_exec_ctx_finish(&exec_ctx);
54
+ grpc_executor_set_threading(false);
55
+ grpc_core::ExecCtx::Get()->Flush();
56
56
  if (!gpr_await_threads(
57
57
  gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
58
58
  gpr_time_from_seconds(3, GPR_TIMESPAN)))) {
@@ -64,24 +64,25 @@ void grpc_prefork() {
64
64
  void grpc_postfork_parent() {
65
65
  if (grpc_is_initialized()) {
66
66
  grpc_timer_manager_set_threading(true);
67
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
68
- grpc_executor_set_threading(&exec_ctx, true);
69
- grpc_exec_ctx_finish(&exec_ctx);
67
+ grpc_core::ExecCtx exec_ctx;
68
+ grpc_executor_set_threading(true);
70
69
  }
71
70
  }
72
71
 
73
72
  void grpc_postfork_child() {
74
73
  if (grpc_is_initialized()) {
75
74
  grpc_timer_manager_set_threading(true);
76
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
77
- grpc_executor_set_threading(&exec_ctx, true);
78
- grpc_exec_ctx_finish(&exec_ctx);
75
+ grpc_core::ExecCtx exec_ctx;
76
+ grpc_executor_set_threading(true);
77
+ grpc_core::ExecCtx::Get()->Flush();
79
78
  }
80
79
  }
81
80
 
82
81
  void grpc_fork_handlers_auto_register() {
83
82
  if (grpc_fork_support_enabled()) {
83
+ #ifdef GRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK
84
84
  pthread_atfork(grpc_prefork, grpc_postfork_parent, grpc_postfork_child);
85
+ #endif // GRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK
85
86
  }
86
87
  }
87
88