grpc 1.57.0 → 1.58.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (402) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +534 -284
  3. data/include/grpc/event_engine/event_engine.h +0 -1
  4. data/include/grpc/event_engine/memory_allocator.h +2 -2
  5. data/include/grpc/impl/channel_arg_names.h +371 -0
  6. data/include/grpc/impl/grpc_types.h +1 -353
  7. data/include/grpc/module.modulemap +1 -0
  8. data/src/core/ext/filters/backend_metrics/backend_metric_filter.cc +1 -1
  9. data/src/core/ext/filters/channel_idle/channel_idle_filter.cc +2 -1
  10. data/src/core/ext/filters/client_channel/client_channel.cc +7 -3
  11. data/src/core/ext/filters/client_channel/http_proxy.cc +1 -1
  12. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.cc +10 -5
  13. data/src/core/ext/filters/client_channel/lb_policy/address_filtering.h +7 -5
  14. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +1 -0
  15. data/src/core/ext/filters/client_channel/lb_policy/health_check_client.cc +5 -3
  16. data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +4 -2
  17. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +115 -109
  18. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.h +0 -5
  19. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +7 -2
  20. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +2 -1
  21. data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +1 -0
  22. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +1 -1
  23. data/src/core/ext/filters/client_channel/lb_policy/weighted_round_robin/weighted_round_robin.cc +11 -3
  24. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +6 -1
  25. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +8 -5
  26. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -1
  27. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +102 -11
  28. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +9 -4
  29. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +4 -1
  30. data/src/core/ext/filters/client_channel/resolver/dns/dns_resolver_plugin.cc +6 -0
  31. data/src/core/ext/filters/client_channel/resolver/dns/event_engine/event_engine_client_channel_resolver.cc +41 -14
  32. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -1
  33. data/src/core/ext/filters/client_channel/resolver/polling_resolver.cc +3 -2
  34. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +1 -1
  35. data/src/core/ext/filters/client_channel/retry_filter.h +1 -0
  36. data/src/core/ext/filters/client_channel/retry_service_config.cc +1 -1
  37. data/src/core/ext/filters/client_channel/service_config_channel_arg_filter.cc +1 -1
  38. data/src/core/ext/filters/client_channel/subchannel.cc +9 -5
  39. data/src/core/ext/filters/client_channel/subchannel.h +8 -2
  40. data/src/core/ext/filters/deadline/deadline_filter.cc +1 -1
  41. data/src/core/ext/filters/http/client/http_client_filter.cc +1 -0
  42. data/src/core/ext/filters/http/client_authority_filter.cc +1 -1
  43. data/src/core/ext/filters/http/message_compress/compression_filter.cc +1 -0
  44. data/src/core/ext/filters/http/server/http_server_filter.cc +1 -1
  45. data/src/core/ext/filters/message_size/message_size_filter.cc +1 -0
  46. data/src/core/ext/filters/rbac/rbac_service_config_parser.cc +4 -7
  47. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +1 -0
  48. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +8 -12
  49. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +357 -358
  50. data/src/core/ext/transport/chttp2/transport/frame_ping.cc +5 -18
  51. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +63 -4
  52. data/src/core/ext/transport/chttp2/transport/hpack_parser.h +7 -2
  53. data/src/core/ext/transport/chttp2/transport/internal.h +30 -57
  54. data/src/core/ext/transport/chttp2/transport/parsing.cc +16 -7
  55. data/src/core/ext/transport/chttp2/transport/ping_abuse_policy.cc +80 -0
  56. data/src/core/ext/transport/chttp2/transport/ping_abuse_policy.h +55 -0
  57. data/src/core/ext/transport/chttp2/transport/ping_rate_policy.cc +98 -0
  58. data/src/core/ext/transport/chttp2/transport/ping_rate_policy.h +73 -0
  59. data/src/core/ext/transport/chttp2/transport/writing.cc +81 -89
  60. data/src/core/ext/transport/inproc/inproc_transport.cc +1 -0
  61. data/src/core/ext/xds/xds_client_grpc.cc +1 -0
  62. data/src/core/ext/xds/xds_http_fault_filter.cc +1 -2
  63. data/src/core/ext/xds/xds_http_fault_filter.h +1 -2
  64. data/src/core/ext/xds/xds_http_filters.h +2 -4
  65. data/src/core/ext/xds/xds_http_rbac_filter.cc +3 -8
  66. data/src/core/ext/xds/xds_http_rbac_filter.h +1 -2
  67. data/src/core/ext/xds/xds_http_stateful_session_filter.cc +1 -2
  68. data/src/core/ext/xds/xds_http_stateful_session_filter.h +1 -2
  69. data/src/core/ext/xds/xds_lb_policy_registry.cc +3 -6
  70. data/src/core/ext/xds/xds_routing.cc +2 -2
  71. data/src/core/ext/xds/xds_transport_grpc.cc +1 -0
  72. data/src/core/lib/avl/avl.h +10 -173
  73. data/src/core/lib/channel/call_tracer.cc +289 -0
  74. data/src/core/lib/channel/call_tracer.h +35 -0
  75. data/src/core/lib/channel/channel_args.cc +84 -79
  76. data/src/core/lib/channel/channel_args.h +29 -17
  77. data/src/core/lib/channel/connected_channel.cc +0 -1
  78. data/src/core/lib/channel/promise_based_filter.cc +4 -1
  79. data/src/core/lib/compression/compression_internal.cc +8 -4
  80. data/src/core/lib/debug/stats_data.cc +93 -21
  81. data/src/core/lib/debug/stats_data.h +41 -0
  82. data/src/core/lib/event_engine/ares_resolver.cc +712 -0
  83. data/src/core/lib/event_engine/ares_resolver.h +150 -0
  84. data/src/core/lib/event_engine/cf_engine/cf_engine.cc +9 -3
  85. data/src/core/lib/event_engine/cf_engine/cfstream_endpoint.cc +2 -2
  86. data/src/core/lib/event_engine/cf_engine/dns_service_resolver.cc +229 -0
  87. data/src/core/lib/event_engine/cf_engine/dns_service_resolver.h +117 -0
  88. data/src/core/lib/event_engine/forkable.cc +15 -1
  89. data/src/core/lib/event_engine/forkable.h +15 -0
  90. data/src/core/lib/event_engine/grpc_polled_fd.h +73 -0
  91. data/src/core/lib/event_engine/posix_engine/ev_poll_posix.cc +25 -3
  92. data/src/core/lib/event_engine/posix_engine/ev_poll_posix.h +10 -1
  93. data/src/core/lib/event_engine/posix_engine/grpc_polled_fd_posix.h +197 -0
  94. data/src/core/lib/event_engine/posix_engine/posix_endpoint.cc +3 -3
  95. data/src/core/lib/event_engine/posix_engine/posix_engine.cc +47 -1
  96. data/src/core/lib/event_engine/posix_engine/posix_engine.h +12 -1
  97. data/src/core/lib/event_engine/posix_engine/tcp_socket_utils.cc +1 -0
  98. data/src/core/lib/event_engine/posix_engine/traced_buffer_list.cc +2 -0
  99. data/src/core/lib/event_engine/thread_pool/thread_count.cc +58 -0
  100. data/src/core/lib/event_engine/thread_pool/thread_count.h +161 -0
  101. data/src/core/lib/event_engine/thread_pool/thread_pool_factory.cc +7 -0
  102. data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.cc +86 -111
  103. data/src/core/lib/event_engine/thread_pool/work_stealing_thread_pool.h +15 -61
  104. data/src/core/lib/event_engine/windows/windows_endpoint.cc +3 -4
  105. data/src/core/lib/experiments/config.cc +14 -0
  106. data/src/core/lib/experiments/experiments.cc +141 -304
  107. data/src/core/lib/experiments/experiments.h +16 -17
  108. data/src/core/lib/gprpp/ref_counted.h +3 -1
  109. data/src/core/lib/gprpp/ref_counted_string.cc +44 -0
  110. data/src/core/lib/gprpp/ref_counted_string.h +146 -0
  111. data/src/core/lib/gprpp/time.h +2 -2
  112. data/src/core/lib/gprpp/work_serializer.cc +36 -0
  113. data/src/core/lib/gprpp/work_serializer.h +5 -0
  114. data/src/core/lib/http/httpcli_security_connector.cc +1 -0
  115. data/src/core/lib/iomgr/buffer_list.cc +2 -0
  116. data/src/core/lib/iomgr/event_engine_shims/endpoint.cc +7 -22
  117. data/src/core/lib/iomgr/tcp_posix.cc +3 -3
  118. data/src/core/lib/promise/detail/basic_seq.h +1 -372
  119. data/src/core/lib/promise/detail/seq_state.h +2076 -0
  120. data/src/core/lib/promise/seq.h +19 -2
  121. data/src/core/lib/promise/sleep.h +5 -10
  122. data/src/core/lib/promise/try_seq.h +34 -2
  123. data/src/core/lib/resource_quota/api.cc +1 -0
  124. data/src/core/lib/resource_quota/arena.cc +2 -0
  125. data/src/core/lib/resource_quota/arena.h +42 -8
  126. data/src/core/lib/resource_quota/memory_quota.cc +0 -1
  127. data/src/core/lib/resource_quota/resource_quota.h +1 -0
  128. data/src/core/lib/security/authorization/authorization_policy_provider.h +1 -1
  129. data/src/core/lib/security/authorization/rbac_policy.h +1 -1
  130. data/src/core/lib/security/credentials/external/aws_request_signer.cc +8 -0
  131. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +1 -0
  132. data/src/core/lib/security/credentials/jwt/json_token.cc +17 -0
  133. data/src/core/lib/security/credentials/jwt/json_token.h +4 -0
  134. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +42 -0
  135. data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +1 -0
  136. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +4 -0
  137. data/src/core/lib/security/credentials/tls/tls_credentials.cc +1 -0
  138. data/src/core/lib/security/credentials/xds/xds_credentials.cc +1 -0
  139. data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +1 -0
  140. data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +1 -0
  141. data/src/core/lib/security/security_connector/ssl_utils.cc +1 -0
  142. data/src/core/lib/security/transport/client_auth_filter.cc +8 -5
  143. data/src/core/lib/security/transport/security_handshaker.cc +1 -0
  144. data/src/core/lib/security/transport/server_auth_filter.cc +2 -0
  145. data/src/core/lib/surface/call.cc +32 -8
  146. data/src/core/lib/surface/channel.cc +1 -0
  147. data/src/core/lib/surface/completion_queue.cc +10 -0
  148. data/src/core/lib/surface/init.cc +1 -0
  149. data/src/core/lib/surface/server.cc +67 -64
  150. data/src/core/lib/surface/server.h +1 -15
  151. data/src/core/lib/surface/version.cc +2 -2
  152. data/src/core/tsi/alts/crypt/aes_gcm.cc +27 -2
  153. data/src/core/tsi/ssl_transport_security.cc +11 -0
  154. data/src/ruby/lib/grpc/generic/active_call.rb +9 -14
  155. data/src/ruby/lib/grpc/version.rb +1 -1
  156. data/src/ruby/pb/test/client.rb +16 -0
  157. data/src/ruby/spec/generic/rpc_server_spec.rb +3 -3
  158. data/third_party/abseil-cpp/absl/algorithm/container.h +3 -2
  159. data/third_party/abseil-cpp/absl/base/attributes.h +58 -5
  160. data/third_party/abseil-cpp/absl/base/call_once.h +1 -1
  161. data/third_party/abseil-cpp/absl/base/casts.h +8 -8
  162. data/third_party/abseil-cpp/absl/base/config.h +89 -106
  163. data/third_party/abseil-cpp/absl/base/dynamic_annotations.h +26 -1
  164. data/third_party/abseil-cpp/absl/base/internal/direct_mmap.h +2 -2
  165. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.cc +50 -39
  166. data/third_party/abseil-cpp/absl/base/internal/low_level_alloc.h +2 -1
  167. data/third_party/abseil-cpp/absl/base/internal/prefetch.h +17 -18
  168. data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +32 -3
  169. data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +24 -4
  170. data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +31 -73
  171. data/third_party/abseil-cpp/absl/base/internal/thread_identity.cc +9 -8
  172. data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +11 -11
  173. data/third_party/abseil-cpp/absl/base/internal/throw_delegate.cc +23 -32
  174. data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +2 -3
  175. data/third_party/abseil-cpp/absl/base/options.h +1 -1
  176. data/third_party/abseil-cpp/absl/base/policy_checks.h +3 -3
  177. data/third_party/abseil-cpp/absl/base/prefetch.h +198 -0
  178. data/third_party/abseil-cpp/absl/container/fixed_array.h +54 -29
  179. data/third_party/abseil-cpp/absl/container/flat_hash_map.h +5 -1
  180. data/third_party/abseil-cpp/absl/container/flat_hash_set.h +6 -2
  181. data/third_party/abseil-cpp/absl/container/inlined_vector.h +167 -79
  182. data/third_party/abseil-cpp/absl/container/internal/common_policy_traits.h +1 -1
  183. data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +3 -21
  184. data/third_party/abseil-cpp/absl/container/internal/container_memory.h +1 -1
  185. data/third_party/abseil-cpp/absl/container/internal/hash_function_defaults.h +46 -0
  186. data/third_party/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +2 -0
  187. data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +85 -26
  188. data/third_party/abseil-cpp/absl/container/internal/raw_hash_map.h +35 -18
  189. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.cc +70 -29
  190. data/third_party/abseil-cpp/absl/container/internal/raw_hash_set.h +437 -236
  191. data/third_party/abseil-cpp/absl/crc/crc32c.h +8 -1
  192. data/third_party/abseil-cpp/absl/crc/internal/cpu_detect.cc +14 -8
  193. data/third_party/abseil-cpp/absl/crc/internal/crc.cc +4 -35
  194. data/third_party/abseil-cpp/absl/crc/internal/crc.h +2 -10
  195. data/third_party/abseil-cpp/absl/crc/internal/crc32_x86_arm_combined_simd.h +1 -1
  196. data/third_party/abseil-cpp/absl/crc/internal/crc_cord_state.cc +1 -1
  197. data/third_party/abseil-cpp/absl/crc/internal/crc_cord_state.h +4 -4
  198. data/third_party/abseil-cpp/absl/crc/internal/crc_internal.h +8 -10
  199. data/third_party/abseil-cpp/absl/crc/internal/crc_memcpy_x86_64.cc +17 -19
  200. data/third_party/abseil-cpp/absl/crc/internal/crc_x86_arm_combined.cc +8 -8
  201. data/third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.h +2 -1
  202. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +59 -23
  203. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +1 -1
  204. data/third_party/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc +1 -1
  205. data/third_party/abseil-cpp/absl/debugging/internal/symbolize.h +1 -1
  206. data/third_party/abseil-cpp/absl/debugging/symbolize_elf.inc +43 -19
  207. data/third_party/abseil-cpp/absl/debugging/symbolize_emscripten.inc +3 -0
  208. data/third_party/abseil-cpp/absl/flags/commandlineflag.h +1 -1
  209. data/third_party/abseil-cpp/absl/flags/internal/commandlineflag.cc +1 -1
  210. data/third_party/abseil-cpp/absl/flags/internal/flag.cc +2 -2
  211. data/third_party/abseil-cpp/absl/flags/internal/flag.h +16 -15
  212. data/third_party/abseil-cpp/absl/flags/internal/flag_msvc.inc +1 -1
  213. data/third_party/abseil-cpp/absl/flags/marshalling.cc +43 -2
  214. data/third_party/abseil-cpp/absl/flags/marshalling.h +5 -0
  215. data/third_party/abseil-cpp/absl/functional/any_invocable.h +9 -1
  216. data/third_party/abseil-cpp/absl/functional/bind_front.h +1 -1
  217. data/third_party/abseil-cpp/absl/functional/function_ref.h +3 -3
  218. data/third_party/abseil-cpp/absl/functional/internal/any_invocable.h +37 -24
  219. data/third_party/abseil-cpp/absl/functional/internal/function_ref.h +19 -9
  220. data/third_party/abseil-cpp/absl/hash/hash.h +7 -4
  221. data/third_party/abseil-cpp/absl/hash/internal/hash.h +38 -15
  222. data/third_party/abseil-cpp/absl/hash/internal/low_level_hash.cc +6 -0
  223. data/third_party/abseil-cpp/absl/meta/type_traits.h +48 -373
  224. data/third_party/abseil-cpp/absl/numeric/bits.h +4 -4
  225. data/third_party/abseil-cpp/absl/numeric/int128.cc +20 -8
  226. data/third_party/abseil-cpp/absl/numeric/int128.h +36 -39
  227. data/third_party/abseil-cpp/absl/numeric/int128_have_intrinsic.inc +0 -3
  228. data/third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc +47 -30
  229. data/third_party/abseil-cpp/absl/random/internal/fast_uniform_bits.h +4 -3
  230. data/third_party/abseil-cpp/absl/random/internal/generate_real.h +1 -1
  231. data/third_party/abseil-cpp/absl/random/internal/platform.h +1 -1
  232. data/third_party/abseil-cpp/absl/random/internal/randen_detect.cc +4 -0
  233. data/third_party/abseil-cpp/absl/random/internal/randen_engine.h +1 -1
  234. data/third_party/abseil-cpp/absl/random/internal/randen_hwaes.cc +1 -1
  235. data/third_party/abseil-cpp/absl/random/internal/uniform_helper.h +1 -1
  236. data/third_party/abseil-cpp/absl/status/internal/status_internal.h +4 -0
  237. data/third_party/abseil-cpp/absl/status/internal/statusor_internal.h +12 -24
  238. data/third_party/abseil-cpp/absl/status/status.cc +11 -7
  239. data/third_party/abseil-cpp/absl/status/status.h +11 -2
  240. data/third_party/abseil-cpp/absl/status/statusor.h +22 -8
  241. data/third_party/abseil-cpp/absl/strings/ascii.cc +54 -6
  242. data/third_party/abseil-cpp/absl/strings/charconv.cc +21 -4
  243. data/third_party/abseil-cpp/absl/strings/charconv.h +2 -2
  244. data/third_party/abseil-cpp/absl/strings/cord.cc +1 -2
  245. data/third_party/abseil-cpp/absl/strings/cord.h +32 -5
  246. data/third_party/abseil-cpp/absl/strings/cord_analysis.cc +23 -1
  247. data/third_party/abseil-cpp/absl/strings/cord_analysis.h +18 -0
  248. data/third_party/abseil-cpp/absl/strings/cord_buffer.h +2 -5
  249. data/third_party/abseil-cpp/absl/strings/escaping.cc +10 -32
  250. data/third_party/abseil-cpp/absl/strings/escaping.h +1 -1
  251. data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc +2 -4
  252. data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.h +3 -3
  253. data/third_party/abseil-cpp/absl/strings/internal/cord_internal.cc +0 -1
  254. data/third_party/abseil-cpp/absl/strings/internal/cord_internal.h +15 -13
  255. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree.cc +13 -4
  256. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_btree.h +8 -0
  257. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_consume.cc +5 -3
  258. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_consume.h +4 -7
  259. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_flat.h +8 -0
  260. data/third_party/abseil-cpp/absl/strings/internal/cord_rep_ring.h +2 -2
  261. data/third_party/abseil-cpp/absl/strings/internal/cordz_handle.cc +46 -20
  262. data/third_party/abseil-cpp/absl/strings/internal/cordz_handle.h +1 -34
  263. data/third_party/abseil-cpp/absl/strings/internal/cordz_info.cc +2 -1
  264. data/third_party/abseil-cpp/absl/strings/internal/escaping.cc +23 -0
  265. data/third_party/abseil-cpp/absl/strings/internal/escaping.h +1 -0
  266. data/third_party/abseil-cpp/absl/strings/internal/memutil.cc +2 -77
  267. data/third_party/abseil-cpp/absl/strings/internal/memutil.h +4 -112
  268. data/third_party/abseil-cpp/absl/strings/internal/stl_type_traits.h +1 -1
  269. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.cc +10 -31
  270. data/third_party/abseil-cpp/absl/strings/internal/str_format/arg.h +8 -8
  271. data/third_party/abseil-cpp/absl/strings/internal/str_format/bind.h +5 -20
  272. data/third_party/abseil-cpp/absl/strings/internal/str_format/constexpr_parser.h +1 -0
  273. data/third_party/abseil-cpp/absl/strings/internal/str_format/extension.h +1 -1
  274. data/third_party/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +9 -9
  275. data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +56 -6
  276. data/third_party/abseil-cpp/absl/strings/match.cc +87 -0
  277. data/third_party/abseil-cpp/absl/strings/match.h +19 -0
  278. data/third_party/abseil-cpp/absl/strings/numbers.cc +154 -122
  279. data/third_party/abseil-cpp/absl/strings/numbers.h +1 -6
  280. data/third_party/abseil-cpp/absl/strings/str_cat.cc +7 -50
  281. data/third_party/abseil-cpp/absl/strings/str_cat.h +83 -15
  282. data/third_party/abseil-cpp/absl/strings/str_format.h +6 -3
  283. data/third_party/abseil-cpp/absl/strings/str_split.cc +9 -6
  284. data/third_party/abseil-cpp/absl/strings/string_view.cc +26 -4
  285. data/third_party/abseil-cpp/absl/synchronization/internal/create_thread_identity.cc +5 -0
  286. data/third_party/abseil-cpp/absl/synchronization/internal/futex.h +63 -43
  287. data/third_party/abseil-cpp/absl/synchronization/internal/futex_waiter.cc +111 -0
  288. data/third_party/abseil-cpp/absl/synchronization/internal/futex_waiter.h +63 -0
  289. data/third_party/abseil-cpp/absl/synchronization/internal/graphcycles.cc +11 -7
  290. data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.cc +225 -0
  291. data/third_party/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +122 -114
  292. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.cc +12 -8
  293. data/third_party/abseil-cpp/absl/synchronization/internal/per_thread_sem.h +10 -1
  294. data/third_party/abseil-cpp/absl/synchronization/internal/pthread_waiter.cc +167 -0
  295. data/third_party/abseil-cpp/absl/synchronization/internal/pthread_waiter.h +60 -0
  296. data/third_party/abseil-cpp/absl/synchronization/internal/sem_waiter.cc +122 -0
  297. data/third_party/abseil-cpp/absl/synchronization/internal/sem_waiter.h +65 -0
  298. data/third_party/abseil-cpp/absl/synchronization/internal/stdcpp_waiter.cc +91 -0
  299. data/third_party/abseil-cpp/absl/synchronization/internal/stdcpp_waiter.h +56 -0
  300. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.h +19 -113
  301. data/third_party/abseil-cpp/absl/synchronization/internal/waiter_base.cc +42 -0
  302. data/third_party/abseil-cpp/absl/synchronization/internal/waiter_base.h +90 -0
  303. data/third_party/abseil-cpp/absl/synchronization/internal/win32_waiter.cc +151 -0
  304. data/third_party/abseil-cpp/absl/synchronization/internal/win32_waiter.h +70 -0
  305. data/third_party/abseil-cpp/absl/synchronization/mutex.cc +407 -411
  306. data/third_party/abseil-cpp/absl/synchronization/mutex.h +152 -118
  307. data/third_party/abseil-cpp/absl/time/clock.cc +6 -7
  308. data/third_party/abseil-cpp/absl/time/duration.cc +24 -26
  309. data/third_party/abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h +1 -0
  310. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_fixed.cc +1 -1
  311. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc +3 -3
  312. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.cc +8 -6
  313. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_if.h +6 -3
  314. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.cc +4 -2
  315. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_impl.h +4 -0
  316. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.cc +322 -295
  317. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_info.h +8 -17
  318. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.cc +51 -33
  319. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_libc.h +7 -2
  320. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc +128 -2
  321. data/third_party/abseil-cpp/absl/time/internal/cctz/src/time_zone_posix.h +1 -1
  322. data/third_party/abseil-cpp/absl/time/internal/cctz/src/tzfile.h +5 -1
  323. data/third_party/abseil-cpp/absl/time/internal/cctz/src/zone_info_source.cc +34 -34
  324. data/third_party/abseil-cpp/absl/time/time.cc +9 -2
  325. data/third_party/abseil-cpp/absl/time/time.h +115 -15
  326. data/third_party/abseil-cpp/absl/types/internal/optional.h +0 -52
  327. data/third_party/abseil-cpp/absl/types/internal/span.h +2 -2
  328. data/third_party/abseil-cpp/absl/types/internal/variant.h +2 -2
  329. data/third_party/abseil-cpp/absl/types/optional.h +15 -13
  330. data/third_party/abseil-cpp/absl/types/span.h +1 -2
  331. data/third_party/boringssl-with-bazel/err_data.c +15 -14
  332. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_gentm.c +7 -3
  333. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_strex.c +7 -7
  334. data/third_party/boringssl-with-bazel/src/crypto/asn1/a_utctm.c +7 -3
  335. data/third_party/boringssl-with-bazel/src/crypto/bio/connect.c +5 -5
  336. data/third_party/boringssl-with-bazel/src/crypto/bio/errno.c +92 -0
  337. data/third_party/boringssl-with-bazel/src/crypto/bio/fd.c +4 -48
  338. data/third_party/boringssl-with-bazel/src/crypto/bio/file.c +11 -6
  339. data/third_party/boringssl-with-bazel/src/crypto/bio/internal.h +16 -6
  340. data/third_party/boringssl-with-bazel/src/crypto/bio/socket.c +2 -2
  341. data/third_party/boringssl-with-bazel/src/crypto/bio/socket_helper.c +9 -0
  342. data/third_party/boringssl-with-bazel/src/crypto/bytestring/cbs.c +1 -1
  343. data/third_party/boringssl-with-bazel/src/crypto/conf/conf.c +3 -7
  344. data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_apple.c +0 -2
  345. data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_fuchsia.c +0 -1
  346. data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_linux.c +0 -2
  347. data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_openbsd.c +0 -1
  348. data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_sysreg.c +93 -0
  349. data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_win.c +1 -1
  350. data/third_party/boringssl-with-bazel/src/crypto/cpu_arm_freebsd.c +0 -1
  351. data/third_party/boringssl-with-bazel/src/crypto/cpu_arm_linux.c +0 -2
  352. data/third_party/boringssl-with-bazel/src/crypto/dh_extra/dh_asn1.c +4 -0
  353. data/third_party/boringssl-with-bazel/src/crypto/dh_extra/params.c +5 -0
  354. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/hash_to_curve.c +9 -14
  355. data/third_party/boringssl-with-bazel/src/crypto/ec_extra/internal.h +4 -6
  356. data/third_party/boringssl-with-bazel/src/crypto/err/err.c +10 -11
  357. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/check.c +37 -8
  358. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/dh.c +38 -19
  359. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/dh/internal.h +7 -0
  360. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/self_check/self_check.c +39 -16
  361. data/third_party/boringssl-with-bazel/src/crypto/fipsmodule/service_indicator/service_indicator.c +4 -7
  362. data/third_party/boringssl-with-bazel/src/crypto/hpke/hpke.c +7 -0
  363. data/third_party/boringssl-with-bazel/src/crypto/internal.h +13 -21
  364. data/third_party/boringssl-with-bazel/src/crypto/obj/obj.c +6 -23
  365. data/third_party/boringssl-with-bazel/src/crypto/rand_extra/getentropy.c +4 -0
  366. data/third_party/boringssl-with-bazel/src/crypto/stack/stack.c +5 -0
  367. data/third_party/boringssl-with-bazel/src/crypto/x509/by_dir.c +1 -6
  368. data/third_party/boringssl-with-bazel/src/crypto/x509/by_file.c +0 -3
  369. data/third_party/boringssl-with-bazel/src/crypto/x509/x509_d2.c +1 -3
  370. data/third_party/boringssl-with-bazel/src/crypto/x509v3/v3_alt.c +2 -3
  371. data/third_party/boringssl-with-bazel/src/include/openssl/base.h +9 -1
  372. data/third_party/boringssl-with-bazel/src/include/openssl/bio.h +11 -1
  373. data/third_party/boringssl-with-bazel/src/include/openssl/dh.h +4 -1
  374. data/third_party/boringssl-with-bazel/src/include/openssl/ec.h +7 -9
  375. data/third_party/boringssl-with-bazel/src/include/openssl/hpke.h +6 -2
  376. data/third_party/boringssl-with-bazel/src/include/openssl/span.h +22 -20
  377. data/third_party/boringssl-with-bazel/src/include/openssl/ssl.h +4 -0
  378. data/third_party/boringssl-with-bazel/src/include/openssl/stack.h +20 -12
  379. data/third_party/boringssl-with-bazel/src/include/openssl/target.h +50 -3
  380. data/third_party/boringssl-with-bazel/src/include/openssl/x509.h +0 -4
  381. data/third_party/boringssl-with-bazel/src/ssl/ssl_cipher.cc +2 -2
  382. data/third_party/boringssl-with-bazel/src/ssl/ssl_file.cc +4 -4
  383. data/third_party/boringssl-with-bazel/src/ssl/ssl_lib.cc +2 -0
  384. metadata +39 -31
  385. data/src/core/lib/promise/detail/basic_join.h +0 -197
  386. data/src/core/lib/promise/detail/switch.h +0 -1455
  387. data/src/core/lib/promise/try_join.h +0 -82
  388. data/third_party/abseil-cpp/absl/synchronization/internal/waiter.cc +0 -403
  389. data/third_party/boringssl-with-bazel/src/crypto/cpu_aarch64_freebsd.c +0 -62
  390. data/third_party/boringssl-with-bazel/src/crypto/cpu_arm.c +0 -38
  391. data/third_party/boringssl-with-bazel/src/crypto/cpu_arm_openbsd.c +0 -31
  392. data/third_party/re2/util/benchmark.h +0 -156
  393. data/third_party/re2/util/flags.h +0 -26
  394. data/third_party/re2/util/malloc_counter.h +0 -19
  395. data/third_party/re2/util/pcre.cc +0 -1025
  396. data/third_party/re2/util/pcre.h +0 -681
  397. data/third_party/re2/util/test.h +0 -50
  398. data/third_party/upb/upb/mini_table.h +0 -36
  399. data/third_party/zlib/gzclose.c +0 -25
  400. data/third_party/zlib/gzlib.c +0 -639
  401. data/third_party/zlib/gzread.c +0 -650
  402. data/third_party/zlib/gzwrite.c +0 -677
@@ -0,0 +1,2076 @@
1
+ // Copyright 2023 gRPC authors.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ #ifndef GRPC_SRC_CORE_LIB_PROMISE_DETAIL_SEQ_STATE_H
16
+ #define GRPC_SRC_CORE_LIB_PROMISE_DETAIL_SEQ_STATE_H
17
+
18
+ // This file is generated by tools/codegen/core/gen_seq.py
19
+
20
+ #include <grpc/support/port_platform.h>
21
+
22
+ #include <stdint.h>
23
+
24
+ #include <utility>
25
+
26
+ #include "absl/base/attributes.h"
27
+
28
+ #include <grpc/support/log.h>
29
+
30
+ #include "src/core/lib/gprpp/construct_destruct.h"
31
+ #include "src/core/lib/promise/detail/promise_factory.h"
32
+ #include "src/core/lib/promise/detail/promise_like.h"
33
+ #include "src/core/lib/promise/poll.h"
34
+
35
+ // A sequence under some traits for some set of callables P, Fs.
36
+ // P should be a promise-like object that yields a value.
37
+ // Fs... should be promise-factory-like objects that take the value from the
38
+ // previous step and yield a promise. Note that most of the machinery in
39
+ // PromiseFactory exists to make it possible for those promise-factory-like
40
+ // objects to be anything that's convenient.
41
+ // Traits defines how we move from one step to the next. Traits sets up the
42
+ // wrapping and escape handling for the sequence.
43
+ // Promises return wrapped values that the trait can inspect and unwrap before
44
+ // passing them to the next element of the sequence. The trait can
45
+ // also interpret a wrapped value as an escape value, which terminates
46
+ // evaluation of the sequence immediately yielding a result. Traits for type T
47
+ // have the members:
48
+ // * type UnwrappedType - the type after removing wrapping from T (i.e. for
49
+ // TrySeq, T=StatusOr<U> yields UnwrappedType=U).
50
+ // * type WrappedType - the type after adding wrapping if it doesn't already
51
+ // exist (i.e. for TrySeq if T is not Status/StatusOr/void, then
52
+ // WrappedType=StatusOr<T>; if T is Status then WrappedType=Status (it's
53
+ // already wrapped!))
54
+ // * template <typename Next> void CallFactory(Next* next_factory, T&& value) -
55
+ // call promise factory next_factory with the result of unwrapping value, and
56
+ // return the resulting promise.
57
+ // * template <typename Result, typename RunNext> Poll<Result>
58
+ // CheckResultAndRunNext(T prior, RunNext run_next) - examine the value of
59
+ // prior, and decide to escape or continue. If escaping, return the final
60
+ // sequence value of type Poll<Result>. If continuing, return the value of
61
+ // run_next(std::move(prior)).
62
+ //
63
+ // A state contains the current promise, and the promise factory to turn the
64
+ // result of the current promise into the next state's promise. We play a shell
65
+ // game such that the prior state and our current promise are kept in a union,
66
+ // and the next promise factory is kept alongside in the state struct.
67
+ // Recursively this guarantees that the next functions get initialized once, and
68
+ // destroyed once, and don't need to be moved around in between, which avoids a
69
+ // potential O(n**2) loop of next factory moves had we used a variant of states
70
+ // here. The very first state does not have a prior state, and so that state has
71
+ // a partial specialization below. The final state does not have a next state;
72
+ // that state is inlined in BasicSeq since that was simpler to type.
73
+
74
+ namespace grpc_core {
75
+ namespace promise_detail {
76
+ template <template <typename> class Traits, typename P, typename... Fs>
77
+ struct SeqState;
78
+
79
+ template <template <typename> class Traits, typename P, typename F0>
80
+ struct SeqState<Traits, P, F0> {
81
+ using Promise0 = PromiseLike<P>;
82
+ using PromiseResult0 = typename Promise0::Result;
83
+ using PromiseResultTraits0 = Traits<PromiseResult0>;
84
+ using NextFactory0 =
85
+ OncePromiseFactory<typename PromiseResultTraits0::UnwrappedType, F0>;
86
+ using Promise1 = typename NextFactory0::Promise;
87
+ using PromiseResult1 = typename Promise1::Result;
88
+ using PromiseResultTraits1 = Traits<PromiseResult1>;
89
+ using Result = typename PromiseResultTraits1::WrappedType;
90
+ struct Running0 {
91
+ GPR_NO_UNIQUE_ADDRESS Promise0 current_promise;
92
+ GPR_NO_UNIQUE_ADDRESS NextFactory0 next_factory;
93
+ };
94
+ union {
95
+ GPR_NO_UNIQUE_ADDRESS Running0 prior;
96
+ GPR_NO_UNIQUE_ADDRESS Promise1 current_promise;
97
+ };
98
+ enum class State : uint8_t { kState0, kState1 };
99
+ GPR_NO_UNIQUE_ADDRESS State state = State::kState0;
100
+
101
+ SeqState(P&& p, F0&& f0) noexcept {
102
+ Construct(&prior.current_promise, std::forward<P>(p));
103
+ Construct(&prior.next_factory, std::forward<F0>(f0));
104
+ }
105
+ ~SeqState() {
106
+ switch (state) {
107
+ case State::kState0:
108
+ Destruct(&prior.current_promise);
109
+ goto tail0;
110
+ case State::kState1:
111
+ Destruct(&current_promise);
112
+ return;
113
+ }
114
+ tail0:
115
+ Destruct(&prior.next_factory);
116
+ }
117
+ SeqState(const SeqState& other) noexcept : state(other.state) {
118
+ GPR_ASSERT(state == State::kState0);
119
+ Construct(&prior.current_promise, other.prior.current_promise);
120
+ Construct(&prior.next_factory, other.prior.next_factory);
121
+ }
122
+ SeqState& operator=(const SeqState& other) = delete;
123
+ SeqState(SeqState&& other) noexcept : state(other.state) {
124
+ switch (state) {
125
+ case State::kState0:
126
+ Construct(&prior.current_promise,
127
+ std::move(other.prior.current_promise));
128
+ goto tail0;
129
+ case State::kState1:
130
+ Construct(&current_promise, std::move(other.current_promise));
131
+ return;
132
+ }
133
+ tail0:
134
+ Construct(&prior.next_factory, std::move(other.prior.next_factory));
135
+ }
136
+ SeqState& operator=(SeqState&& other) = delete;
137
+ Poll<Result> PollOnce() {
138
+ switch (state) {
139
+ case State::kState0: {
140
+ auto result = prior.current_promise();
141
+ PromiseResult0* p = result.value_if_ready();
142
+ if (p == nullptr) return Pending{};
143
+ if (!PromiseResultTraits0::IsOk(*p)) {
144
+ return PromiseResultTraits0::template ReturnValue<Result>(
145
+ std::move(*p));
146
+ }
147
+ Destruct(&prior.current_promise);
148
+ auto next_promise = PromiseResultTraits0::CallFactory(
149
+ &prior.next_factory, std::move(*p));
150
+ Destruct(&prior.next_factory);
151
+ Construct(&current_promise, std::move(next_promise));
152
+ state = State::kState1;
153
+ }
154
+ ABSL_FALLTHROUGH_INTENDED;
155
+ default:
156
+ case State::kState1: {
157
+ auto result = current_promise();
158
+ auto* p = result.value_if_ready();
159
+ if (p == nullptr) return Pending{};
160
+ return Result(std::move(*p));
161
+ }
162
+ }
163
+ }
164
+ };
165
+
166
+ template <template <typename> class Traits, typename P, typename F0,
167
+ typename F1>
168
+ struct SeqState<Traits, P, F0, F1> {
169
+ using Promise0 = PromiseLike<P>;
170
+ using PromiseResult0 = typename Promise0::Result;
171
+ using PromiseResultTraits0 = Traits<PromiseResult0>;
172
+ using NextFactory0 =
173
+ OncePromiseFactory<typename PromiseResultTraits0::UnwrappedType, F0>;
174
+ using Promise1 = typename NextFactory0::Promise;
175
+ using PromiseResult1 = typename Promise1::Result;
176
+ using PromiseResultTraits1 = Traits<PromiseResult1>;
177
+ using NextFactory1 =
178
+ OncePromiseFactory<typename PromiseResultTraits1::UnwrappedType, F1>;
179
+ using Promise2 = typename NextFactory1::Promise;
180
+ using PromiseResult2 = typename Promise2::Result;
181
+ using PromiseResultTraits2 = Traits<PromiseResult2>;
182
+ using Result = typename PromiseResultTraits2::WrappedType;
183
+ struct Running0 {
184
+ GPR_NO_UNIQUE_ADDRESS Promise0 current_promise;
185
+ GPR_NO_UNIQUE_ADDRESS NextFactory0 next_factory;
186
+ };
187
+ struct Running1 {
188
+ union {
189
+ GPR_NO_UNIQUE_ADDRESS Running0 prior;
190
+ GPR_NO_UNIQUE_ADDRESS Promise1 current_promise;
191
+ };
192
+ GPR_NO_UNIQUE_ADDRESS NextFactory1 next_factory;
193
+ };
194
+ union {
195
+ GPR_NO_UNIQUE_ADDRESS Running1 prior;
196
+ GPR_NO_UNIQUE_ADDRESS Promise2 current_promise;
197
+ };
198
+ enum class State : uint8_t { kState0, kState1, kState2 };
199
+ GPR_NO_UNIQUE_ADDRESS State state = State::kState0;
200
+
201
+ SeqState(P&& p, F0&& f0, F1&& f1) noexcept {
202
+ Construct(&prior.prior.current_promise, std::forward<P>(p));
203
+ Construct(&prior.prior.next_factory, std::forward<F0>(f0));
204
+ Construct(&prior.next_factory, std::forward<F1>(f1));
205
+ }
206
+ ~SeqState() {
207
+ switch (state) {
208
+ case State::kState0:
209
+ Destruct(&prior.prior.current_promise);
210
+ goto tail0;
211
+ case State::kState1:
212
+ Destruct(&prior.current_promise);
213
+ goto tail1;
214
+ case State::kState2:
215
+ Destruct(&current_promise);
216
+ return;
217
+ }
218
+ tail0:
219
+ Destruct(&prior.prior.next_factory);
220
+ tail1:
221
+ Destruct(&prior.next_factory);
222
+ }
223
+ SeqState(const SeqState& other) noexcept : state(other.state) {
224
+ GPR_ASSERT(state == State::kState0);
225
+ Construct(&prior.current_promise, other.prior.current_promise);
226
+ Construct(&prior.prior.next_factory, other.prior.prior.next_factory);
227
+ Construct(&prior.next_factory, other.prior.next_factory);
228
+ }
229
+ SeqState& operator=(const SeqState& other) = delete;
230
+ SeqState(SeqState&& other) noexcept : state(other.state) {
231
+ switch (state) {
232
+ case State::kState0:
233
+ Construct(&prior.prior.current_promise,
234
+ std::move(other.prior.prior.current_promise));
235
+ goto tail0;
236
+ case State::kState1:
237
+ Construct(&prior.current_promise,
238
+ std::move(other.prior.current_promise));
239
+ goto tail1;
240
+ case State::kState2:
241
+ Construct(&current_promise, std::move(other.current_promise));
242
+ return;
243
+ }
244
+ tail0:
245
+ Construct(&prior.prior.next_factory,
246
+ std::move(other.prior.prior.next_factory));
247
+ tail1:
248
+ Construct(&prior.next_factory, std::move(other.prior.next_factory));
249
+ }
250
+ SeqState& operator=(SeqState&& other) = delete;
251
+ Poll<Result> PollOnce() {
252
+ switch (state) {
253
+ case State::kState0: {
254
+ auto result = prior.prior.current_promise();
255
+ PromiseResult0* p = result.value_if_ready();
256
+ if (p == nullptr) return Pending{};
257
+ if (!PromiseResultTraits0::IsOk(*p)) {
258
+ return PromiseResultTraits0::template ReturnValue<Result>(
259
+ std::move(*p));
260
+ }
261
+ Destruct(&prior.prior.current_promise);
262
+ auto next_promise = PromiseResultTraits0::CallFactory(
263
+ &prior.prior.next_factory, std::move(*p));
264
+ Destruct(&prior.prior.next_factory);
265
+ Construct(&prior.current_promise, std::move(next_promise));
266
+ state = State::kState1;
267
+ }
268
+ ABSL_FALLTHROUGH_INTENDED;
269
+ case State::kState1: {
270
+ auto result = prior.current_promise();
271
+ PromiseResult1* p = result.value_if_ready();
272
+ if (p == nullptr) return Pending{};
273
+ if (!PromiseResultTraits1::IsOk(*p)) {
274
+ return PromiseResultTraits1::template ReturnValue<Result>(
275
+ std::move(*p));
276
+ }
277
+ Destruct(&prior.current_promise);
278
+ auto next_promise = PromiseResultTraits1::CallFactory(
279
+ &prior.next_factory, std::move(*p));
280
+ Destruct(&prior.next_factory);
281
+ Construct(&current_promise, std::move(next_promise));
282
+ state = State::kState2;
283
+ }
284
+ ABSL_FALLTHROUGH_INTENDED;
285
+ default:
286
+ case State::kState2: {
287
+ auto result = current_promise();
288
+ auto* p = result.value_if_ready();
289
+ if (p == nullptr) return Pending{};
290
+ return Result(std::move(*p));
291
+ }
292
+ }
293
+ }
294
+ };
295
+
296
+ template <template <typename> class Traits, typename P, typename F0,
297
+ typename F1, typename F2>
298
+ struct SeqState<Traits, P, F0, F1, F2> {
299
+ using Promise0 = PromiseLike<P>;
300
+ using PromiseResult0 = typename Promise0::Result;
301
+ using PromiseResultTraits0 = Traits<PromiseResult0>;
302
+ using NextFactory0 =
303
+ OncePromiseFactory<typename PromiseResultTraits0::UnwrappedType, F0>;
304
+ using Promise1 = typename NextFactory0::Promise;
305
+ using PromiseResult1 = typename Promise1::Result;
306
+ using PromiseResultTraits1 = Traits<PromiseResult1>;
307
+ using NextFactory1 =
308
+ OncePromiseFactory<typename PromiseResultTraits1::UnwrappedType, F1>;
309
+ using Promise2 = typename NextFactory1::Promise;
310
+ using PromiseResult2 = typename Promise2::Result;
311
+ using PromiseResultTraits2 = Traits<PromiseResult2>;
312
+ using NextFactory2 =
313
+ OncePromiseFactory<typename PromiseResultTraits2::UnwrappedType, F2>;
314
+ using Promise3 = typename NextFactory2::Promise;
315
+ using PromiseResult3 = typename Promise3::Result;
316
+ using PromiseResultTraits3 = Traits<PromiseResult3>;
317
+ using Result = typename PromiseResultTraits3::WrappedType;
318
+ struct Running0 {
319
+ GPR_NO_UNIQUE_ADDRESS Promise0 current_promise;
320
+ GPR_NO_UNIQUE_ADDRESS NextFactory0 next_factory;
321
+ };
322
+ struct Running1 {
323
+ union {
324
+ GPR_NO_UNIQUE_ADDRESS Running0 prior;
325
+ GPR_NO_UNIQUE_ADDRESS Promise1 current_promise;
326
+ };
327
+ GPR_NO_UNIQUE_ADDRESS NextFactory1 next_factory;
328
+ };
329
+ struct Running2 {
330
+ union {
331
+ GPR_NO_UNIQUE_ADDRESS Running1 prior;
332
+ GPR_NO_UNIQUE_ADDRESS Promise2 current_promise;
333
+ };
334
+ GPR_NO_UNIQUE_ADDRESS NextFactory2 next_factory;
335
+ };
336
+ union {
337
+ GPR_NO_UNIQUE_ADDRESS Running2 prior;
338
+ GPR_NO_UNIQUE_ADDRESS Promise3 current_promise;
339
+ };
340
+ enum class State : uint8_t { kState0, kState1, kState2, kState3 };
341
+ GPR_NO_UNIQUE_ADDRESS State state = State::kState0;
342
+
343
+ SeqState(P&& p, F0&& f0, F1&& f1, F2&& f2) noexcept {
344
+ Construct(&prior.prior.prior.current_promise, std::forward<P>(p));
345
+ Construct(&prior.prior.prior.next_factory, std::forward<F0>(f0));
346
+ Construct(&prior.prior.next_factory, std::forward<F1>(f1));
347
+ Construct(&prior.next_factory, std::forward<F2>(f2));
348
+ }
349
+ ~SeqState() {
350
+ switch (state) {
351
+ case State::kState0:
352
+ Destruct(&prior.prior.prior.current_promise);
353
+ goto tail0;
354
+ case State::kState1:
355
+ Destruct(&prior.prior.current_promise);
356
+ goto tail1;
357
+ case State::kState2:
358
+ Destruct(&prior.current_promise);
359
+ goto tail2;
360
+ case State::kState3:
361
+ Destruct(&current_promise);
362
+ return;
363
+ }
364
+ tail0:
365
+ Destruct(&prior.prior.prior.next_factory);
366
+ tail1:
367
+ Destruct(&prior.prior.next_factory);
368
+ tail2:
369
+ Destruct(&prior.next_factory);
370
+ }
371
+ SeqState(const SeqState& other) noexcept : state(other.state) {
372
+ GPR_ASSERT(state == State::kState0);
373
+ Construct(&prior.current_promise, other.prior.current_promise);
374
+ Construct(&prior.prior.prior.next_factory,
375
+ other.prior.prior.prior.next_factory);
376
+ Construct(&prior.prior.next_factory, other.prior.prior.next_factory);
377
+ Construct(&prior.next_factory, other.prior.next_factory);
378
+ }
379
+ SeqState& operator=(const SeqState& other) = delete;
380
+ SeqState(SeqState&& other) noexcept : state(other.state) {
381
+ switch (state) {
382
+ case State::kState0:
383
+ Construct(&prior.prior.prior.current_promise,
384
+ std::move(other.prior.prior.prior.current_promise));
385
+ goto tail0;
386
+ case State::kState1:
387
+ Construct(&prior.prior.current_promise,
388
+ std::move(other.prior.prior.current_promise));
389
+ goto tail1;
390
+ case State::kState2:
391
+ Construct(&prior.current_promise,
392
+ std::move(other.prior.current_promise));
393
+ goto tail2;
394
+ case State::kState3:
395
+ Construct(&current_promise, std::move(other.current_promise));
396
+ return;
397
+ }
398
+ tail0:
399
+ Construct(&prior.prior.prior.next_factory,
400
+ std::move(other.prior.prior.prior.next_factory));
401
+ tail1:
402
+ Construct(&prior.prior.next_factory,
403
+ std::move(other.prior.prior.next_factory));
404
+ tail2:
405
+ Construct(&prior.next_factory, std::move(other.prior.next_factory));
406
+ }
407
+ SeqState& operator=(SeqState&& other) = delete;
408
+ Poll<Result> PollOnce() {
409
+ switch (state) {
410
+ case State::kState0: {
411
+ auto result = prior.prior.prior.current_promise();
412
+ PromiseResult0* p = result.value_if_ready();
413
+ if (p == nullptr) return Pending{};
414
+ if (!PromiseResultTraits0::IsOk(*p)) {
415
+ return PromiseResultTraits0::template ReturnValue<Result>(
416
+ std::move(*p));
417
+ }
418
+ Destruct(&prior.prior.prior.current_promise);
419
+ auto next_promise = PromiseResultTraits0::CallFactory(
420
+ &prior.prior.prior.next_factory, std::move(*p));
421
+ Destruct(&prior.prior.prior.next_factory);
422
+ Construct(&prior.prior.current_promise, std::move(next_promise));
423
+ state = State::kState1;
424
+ }
425
+ ABSL_FALLTHROUGH_INTENDED;
426
+ case State::kState1: {
427
+ auto result = prior.prior.current_promise();
428
+ PromiseResult1* p = result.value_if_ready();
429
+ if (p == nullptr) return Pending{};
430
+ if (!PromiseResultTraits1::IsOk(*p)) {
431
+ return PromiseResultTraits1::template ReturnValue<Result>(
432
+ std::move(*p));
433
+ }
434
+ Destruct(&prior.prior.current_promise);
435
+ auto next_promise = PromiseResultTraits1::CallFactory(
436
+ &prior.prior.next_factory, std::move(*p));
437
+ Destruct(&prior.prior.next_factory);
438
+ Construct(&prior.current_promise, std::move(next_promise));
439
+ state = State::kState2;
440
+ }
441
+ ABSL_FALLTHROUGH_INTENDED;
442
+ case State::kState2: {
443
+ auto result = prior.current_promise();
444
+ PromiseResult2* p = result.value_if_ready();
445
+ if (p == nullptr) return Pending{};
446
+ if (!PromiseResultTraits2::IsOk(*p)) {
447
+ return PromiseResultTraits2::template ReturnValue<Result>(
448
+ std::move(*p));
449
+ }
450
+ Destruct(&prior.current_promise);
451
+ auto next_promise = PromiseResultTraits2::CallFactory(
452
+ &prior.next_factory, std::move(*p));
453
+ Destruct(&prior.next_factory);
454
+ Construct(&current_promise, std::move(next_promise));
455
+ state = State::kState3;
456
+ }
457
+ ABSL_FALLTHROUGH_INTENDED;
458
+ default:
459
+ case State::kState3: {
460
+ auto result = current_promise();
461
+ auto* p = result.value_if_ready();
462
+ if (p == nullptr) return Pending{};
463
+ return Result(std::move(*p));
464
+ }
465
+ }
466
+ }
467
+ };
468
+
469
+ template <template <typename> class Traits, typename P, typename F0,
470
+ typename F1, typename F2, typename F3>
471
+ struct SeqState<Traits, P, F0, F1, F2, F3> {
472
+ using Promise0 = PromiseLike<P>;
473
+ using PromiseResult0 = typename Promise0::Result;
474
+ using PromiseResultTraits0 = Traits<PromiseResult0>;
475
+ using NextFactory0 =
476
+ OncePromiseFactory<typename PromiseResultTraits0::UnwrappedType, F0>;
477
+ using Promise1 = typename NextFactory0::Promise;
478
+ using PromiseResult1 = typename Promise1::Result;
479
+ using PromiseResultTraits1 = Traits<PromiseResult1>;
480
+ using NextFactory1 =
481
+ OncePromiseFactory<typename PromiseResultTraits1::UnwrappedType, F1>;
482
+ using Promise2 = typename NextFactory1::Promise;
483
+ using PromiseResult2 = typename Promise2::Result;
484
+ using PromiseResultTraits2 = Traits<PromiseResult2>;
485
+ using NextFactory2 =
486
+ OncePromiseFactory<typename PromiseResultTraits2::UnwrappedType, F2>;
487
+ using Promise3 = typename NextFactory2::Promise;
488
+ using PromiseResult3 = typename Promise3::Result;
489
+ using PromiseResultTraits3 = Traits<PromiseResult3>;
490
+ using NextFactory3 =
491
+ OncePromiseFactory<typename PromiseResultTraits3::UnwrappedType, F3>;
492
+ using Promise4 = typename NextFactory3::Promise;
493
+ using PromiseResult4 = typename Promise4::Result;
494
+ using PromiseResultTraits4 = Traits<PromiseResult4>;
495
+ using Result = typename PromiseResultTraits4::WrappedType;
496
+ struct Running0 {
497
+ GPR_NO_UNIQUE_ADDRESS Promise0 current_promise;
498
+ GPR_NO_UNIQUE_ADDRESS NextFactory0 next_factory;
499
+ };
500
+ struct Running1 {
501
+ union {
502
+ GPR_NO_UNIQUE_ADDRESS Running0 prior;
503
+ GPR_NO_UNIQUE_ADDRESS Promise1 current_promise;
504
+ };
505
+ GPR_NO_UNIQUE_ADDRESS NextFactory1 next_factory;
506
+ };
507
+ struct Running2 {
508
+ union {
509
+ GPR_NO_UNIQUE_ADDRESS Running1 prior;
510
+ GPR_NO_UNIQUE_ADDRESS Promise2 current_promise;
511
+ };
512
+ GPR_NO_UNIQUE_ADDRESS NextFactory2 next_factory;
513
+ };
514
+ struct Running3 {
515
+ union {
516
+ GPR_NO_UNIQUE_ADDRESS Running2 prior;
517
+ GPR_NO_UNIQUE_ADDRESS Promise3 current_promise;
518
+ };
519
+ GPR_NO_UNIQUE_ADDRESS NextFactory3 next_factory;
520
+ };
521
+ union {
522
+ GPR_NO_UNIQUE_ADDRESS Running3 prior;
523
+ GPR_NO_UNIQUE_ADDRESS Promise4 current_promise;
524
+ };
525
+ enum class State : uint8_t { kState0, kState1, kState2, kState3, kState4 };
526
+ GPR_NO_UNIQUE_ADDRESS State state = State::kState0;
527
+
528
+ SeqState(P&& p, F0&& f0, F1&& f1, F2&& f2, F3&& f3) noexcept {
529
+ Construct(&prior.prior.prior.prior.current_promise, std::forward<P>(p));
530
+ Construct(&prior.prior.prior.prior.next_factory, std::forward<F0>(f0));
531
+ Construct(&prior.prior.prior.next_factory, std::forward<F1>(f1));
532
+ Construct(&prior.prior.next_factory, std::forward<F2>(f2));
533
+ Construct(&prior.next_factory, std::forward<F3>(f3));
534
+ }
535
+ ~SeqState() {
536
+ switch (state) {
537
+ case State::kState0:
538
+ Destruct(&prior.prior.prior.prior.current_promise);
539
+ goto tail0;
540
+ case State::kState1:
541
+ Destruct(&prior.prior.prior.current_promise);
542
+ goto tail1;
543
+ case State::kState2:
544
+ Destruct(&prior.prior.current_promise);
545
+ goto tail2;
546
+ case State::kState3:
547
+ Destruct(&prior.current_promise);
548
+ goto tail3;
549
+ case State::kState4:
550
+ Destruct(&current_promise);
551
+ return;
552
+ }
553
+ tail0:
554
+ Destruct(&prior.prior.prior.prior.next_factory);
555
+ tail1:
556
+ Destruct(&prior.prior.prior.next_factory);
557
+ tail2:
558
+ Destruct(&prior.prior.next_factory);
559
+ tail3:
560
+ Destruct(&prior.next_factory);
561
+ }
562
+ SeqState(const SeqState& other) noexcept : state(other.state) {
563
+ GPR_ASSERT(state == State::kState0);
564
+ Construct(&prior.current_promise, other.prior.current_promise);
565
+ Construct(&prior.prior.prior.prior.next_factory,
566
+ other.prior.prior.prior.prior.next_factory);
567
+ Construct(&prior.prior.prior.next_factory,
568
+ other.prior.prior.prior.next_factory);
569
+ Construct(&prior.prior.next_factory, other.prior.prior.next_factory);
570
+ Construct(&prior.next_factory, other.prior.next_factory);
571
+ }
572
+ SeqState& operator=(const SeqState& other) = delete;
573
+ SeqState(SeqState&& other) noexcept : state(other.state) {
574
+ switch (state) {
575
+ case State::kState0:
576
+ Construct(&prior.prior.prior.prior.current_promise,
577
+ std::move(other.prior.prior.prior.prior.current_promise));
578
+ goto tail0;
579
+ case State::kState1:
580
+ Construct(&prior.prior.prior.current_promise,
581
+ std::move(other.prior.prior.prior.current_promise));
582
+ goto tail1;
583
+ case State::kState2:
584
+ Construct(&prior.prior.current_promise,
585
+ std::move(other.prior.prior.current_promise));
586
+ goto tail2;
587
+ case State::kState3:
588
+ Construct(&prior.current_promise,
589
+ std::move(other.prior.current_promise));
590
+ goto tail3;
591
+ case State::kState4:
592
+ Construct(&current_promise, std::move(other.current_promise));
593
+ return;
594
+ }
595
+ tail0:
596
+ Construct(&prior.prior.prior.prior.next_factory,
597
+ std::move(other.prior.prior.prior.prior.next_factory));
598
+ tail1:
599
+ Construct(&prior.prior.prior.next_factory,
600
+ std::move(other.prior.prior.prior.next_factory));
601
+ tail2:
602
+ Construct(&prior.prior.next_factory,
603
+ std::move(other.prior.prior.next_factory));
604
+ tail3:
605
+ Construct(&prior.next_factory, std::move(other.prior.next_factory));
606
+ }
607
+ SeqState& operator=(SeqState&& other) = delete;
608
+ Poll<Result> PollOnce() {
609
+ switch (state) {
610
+ case State::kState0: {
611
+ auto result = prior.prior.prior.prior.current_promise();
612
+ PromiseResult0* p = result.value_if_ready();
613
+ if (p == nullptr) return Pending{};
614
+ if (!PromiseResultTraits0::IsOk(*p)) {
615
+ return PromiseResultTraits0::template ReturnValue<Result>(
616
+ std::move(*p));
617
+ }
618
+ Destruct(&prior.prior.prior.prior.current_promise);
619
+ auto next_promise = PromiseResultTraits0::CallFactory(
620
+ &prior.prior.prior.prior.next_factory, std::move(*p));
621
+ Destruct(&prior.prior.prior.prior.next_factory);
622
+ Construct(&prior.prior.prior.current_promise, std::move(next_promise));
623
+ state = State::kState1;
624
+ }
625
+ ABSL_FALLTHROUGH_INTENDED;
626
+ case State::kState1: {
627
+ auto result = prior.prior.prior.current_promise();
628
+ PromiseResult1* p = result.value_if_ready();
629
+ if (p == nullptr) return Pending{};
630
+ if (!PromiseResultTraits1::IsOk(*p)) {
631
+ return PromiseResultTraits1::template ReturnValue<Result>(
632
+ std::move(*p));
633
+ }
634
+ Destruct(&prior.prior.prior.current_promise);
635
+ auto next_promise = PromiseResultTraits1::CallFactory(
636
+ &prior.prior.prior.next_factory, std::move(*p));
637
+ Destruct(&prior.prior.prior.next_factory);
638
+ Construct(&prior.prior.current_promise, std::move(next_promise));
639
+ state = State::kState2;
640
+ }
641
+ ABSL_FALLTHROUGH_INTENDED;
642
+ case State::kState2: {
643
+ auto result = prior.prior.current_promise();
644
+ PromiseResult2* p = result.value_if_ready();
645
+ if (p == nullptr) return Pending{};
646
+ if (!PromiseResultTraits2::IsOk(*p)) {
647
+ return PromiseResultTraits2::template ReturnValue<Result>(
648
+ std::move(*p));
649
+ }
650
+ Destruct(&prior.prior.current_promise);
651
+ auto next_promise = PromiseResultTraits2::CallFactory(
652
+ &prior.prior.next_factory, std::move(*p));
653
+ Destruct(&prior.prior.next_factory);
654
+ Construct(&prior.current_promise, std::move(next_promise));
655
+ state = State::kState3;
656
+ }
657
+ ABSL_FALLTHROUGH_INTENDED;
658
+ case State::kState3: {
659
+ auto result = prior.current_promise();
660
+ PromiseResult3* p = result.value_if_ready();
661
+ if (p == nullptr) return Pending{};
662
+ if (!PromiseResultTraits3::IsOk(*p)) {
663
+ return PromiseResultTraits3::template ReturnValue<Result>(
664
+ std::move(*p));
665
+ }
666
+ Destruct(&prior.current_promise);
667
+ auto next_promise = PromiseResultTraits3::CallFactory(
668
+ &prior.next_factory, std::move(*p));
669
+ Destruct(&prior.next_factory);
670
+ Construct(&current_promise, std::move(next_promise));
671
+ state = State::kState4;
672
+ }
673
+ ABSL_FALLTHROUGH_INTENDED;
674
+ default:
675
+ case State::kState4: {
676
+ auto result = current_promise();
677
+ auto* p = result.value_if_ready();
678
+ if (p == nullptr) return Pending{};
679
+ return Result(std::move(*p));
680
+ }
681
+ }
682
+ }
683
+ };
684
+
685
+ template <template <typename> class Traits, typename P, typename F0,
686
+ typename F1, typename F2, typename F3, typename F4>
687
+ struct SeqState<Traits, P, F0, F1, F2, F3, F4> {
688
+ using Promise0 = PromiseLike<P>;
689
+ using PromiseResult0 = typename Promise0::Result;
690
+ using PromiseResultTraits0 = Traits<PromiseResult0>;
691
+ using NextFactory0 =
692
+ OncePromiseFactory<typename PromiseResultTraits0::UnwrappedType, F0>;
693
+ using Promise1 = typename NextFactory0::Promise;
694
+ using PromiseResult1 = typename Promise1::Result;
695
+ using PromiseResultTraits1 = Traits<PromiseResult1>;
696
+ using NextFactory1 =
697
+ OncePromiseFactory<typename PromiseResultTraits1::UnwrappedType, F1>;
698
+ using Promise2 = typename NextFactory1::Promise;
699
+ using PromiseResult2 = typename Promise2::Result;
700
+ using PromiseResultTraits2 = Traits<PromiseResult2>;
701
+ using NextFactory2 =
702
+ OncePromiseFactory<typename PromiseResultTraits2::UnwrappedType, F2>;
703
+ using Promise3 = typename NextFactory2::Promise;
704
+ using PromiseResult3 = typename Promise3::Result;
705
+ using PromiseResultTraits3 = Traits<PromiseResult3>;
706
+ using NextFactory3 =
707
+ OncePromiseFactory<typename PromiseResultTraits3::UnwrappedType, F3>;
708
+ using Promise4 = typename NextFactory3::Promise;
709
+ using PromiseResult4 = typename Promise4::Result;
710
+ using PromiseResultTraits4 = Traits<PromiseResult4>;
711
+ using NextFactory4 =
712
+ OncePromiseFactory<typename PromiseResultTraits4::UnwrappedType, F4>;
713
+ using Promise5 = typename NextFactory4::Promise;
714
+ using PromiseResult5 = typename Promise5::Result;
715
+ using PromiseResultTraits5 = Traits<PromiseResult5>;
716
+ using Result = typename PromiseResultTraits5::WrappedType;
717
+ struct Running0 {
718
+ GPR_NO_UNIQUE_ADDRESS Promise0 current_promise;
719
+ GPR_NO_UNIQUE_ADDRESS NextFactory0 next_factory;
720
+ };
721
+ struct Running1 {
722
+ union {
723
+ GPR_NO_UNIQUE_ADDRESS Running0 prior;
724
+ GPR_NO_UNIQUE_ADDRESS Promise1 current_promise;
725
+ };
726
+ GPR_NO_UNIQUE_ADDRESS NextFactory1 next_factory;
727
+ };
728
+ struct Running2 {
729
+ union {
730
+ GPR_NO_UNIQUE_ADDRESS Running1 prior;
731
+ GPR_NO_UNIQUE_ADDRESS Promise2 current_promise;
732
+ };
733
+ GPR_NO_UNIQUE_ADDRESS NextFactory2 next_factory;
734
+ };
735
+ struct Running3 {
736
+ union {
737
+ GPR_NO_UNIQUE_ADDRESS Running2 prior;
738
+ GPR_NO_UNIQUE_ADDRESS Promise3 current_promise;
739
+ };
740
+ GPR_NO_UNIQUE_ADDRESS NextFactory3 next_factory;
741
+ };
742
+ struct Running4 {
743
+ union {
744
+ GPR_NO_UNIQUE_ADDRESS Running3 prior;
745
+ GPR_NO_UNIQUE_ADDRESS Promise4 current_promise;
746
+ };
747
+ GPR_NO_UNIQUE_ADDRESS NextFactory4 next_factory;
748
+ };
749
+ union {
750
+ GPR_NO_UNIQUE_ADDRESS Running4 prior;
751
+ GPR_NO_UNIQUE_ADDRESS Promise5 current_promise;
752
+ };
753
+ enum class State : uint8_t {
754
+ kState0,
755
+ kState1,
756
+ kState2,
757
+ kState3,
758
+ kState4,
759
+ kState5
760
+ };
761
+ GPR_NO_UNIQUE_ADDRESS State state = State::kState0;
762
+
763
+ SeqState(P&& p, F0&& f0, F1&& f1, F2&& f2, F3&& f3, F4&& f4) noexcept {
764
+ Construct(&prior.prior.prior.prior.prior.current_promise,
765
+ std::forward<P>(p));
766
+ Construct(&prior.prior.prior.prior.prior.next_factory,
767
+ std::forward<F0>(f0));
768
+ Construct(&prior.prior.prior.prior.next_factory, std::forward<F1>(f1));
769
+ Construct(&prior.prior.prior.next_factory, std::forward<F2>(f2));
770
+ Construct(&prior.prior.next_factory, std::forward<F3>(f3));
771
+ Construct(&prior.next_factory, std::forward<F4>(f4));
772
+ }
773
+ ~SeqState() {
774
+ switch (state) {
775
+ case State::kState0:
776
+ Destruct(&prior.prior.prior.prior.prior.current_promise);
777
+ goto tail0;
778
+ case State::kState1:
779
+ Destruct(&prior.prior.prior.prior.current_promise);
780
+ goto tail1;
781
+ case State::kState2:
782
+ Destruct(&prior.prior.prior.current_promise);
783
+ goto tail2;
784
+ case State::kState3:
785
+ Destruct(&prior.prior.current_promise);
786
+ goto tail3;
787
+ case State::kState4:
788
+ Destruct(&prior.current_promise);
789
+ goto tail4;
790
+ case State::kState5:
791
+ Destruct(&current_promise);
792
+ return;
793
+ }
794
+ tail0:
795
+ Destruct(&prior.prior.prior.prior.prior.next_factory);
796
+ tail1:
797
+ Destruct(&prior.prior.prior.prior.next_factory);
798
+ tail2:
799
+ Destruct(&prior.prior.prior.next_factory);
800
+ tail3:
801
+ Destruct(&prior.prior.next_factory);
802
+ tail4:
803
+ Destruct(&prior.next_factory);
804
+ }
805
+ SeqState(const SeqState& other) noexcept : state(other.state) {
806
+ GPR_ASSERT(state == State::kState0);
807
+ Construct(&prior.current_promise, other.prior.current_promise);
808
+ Construct(&prior.prior.prior.prior.prior.next_factory,
809
+ other.prior.prior.prior.prior.prior.next_factory);
810
+ Construct(&prior.prior.prior.prior.next_factory,
811
+ other.prior.prior.prior.prior.next_factory);
812
+ Construct(&prior.prior.prior.next_factory,
813
+ other.prior.prior.prior.next_factory);
814
+ Construct(&prior.prior.next_factory, other.prior.prior.next_factory);
815
+ Construct(&prior.next_factory, other.prior.next_factory);
816
+ }
817
+ SeqState& operator=(const SeqState& other) = delete;
818
+ SeqState(SeqState&& other) noexcept : state(other.state) {
819
+ switch (state) {
820
+ case State::kState0:
821
+ Construct(
822
+ &prior.prior.prior.prior.prior.current_promise,
823
+ std::move(other.prior.prior.prior.prior.prior.current_promise));
824
+ goto tail0;
825
+ case State::kState1:
826
+ Construct(&prior.prior.prior.prior.current_promise,
827
+ std::move(other.prior.prior.prior.prior.current_promise));
828
+ goto tail1;
829
+ case State::kState2:
830
+ Construct(&prior.prior.prior.current_promise,
831
+ std::move(other.prior.prior.prior.current_promise));
832
+ goto tail2;
833
+ case State::kState3:
834
+ Construct(&prior.prior.current_promise,
835
+ std::move(other.prior.prior.current_promise));
836
+ goto tail3;
837
+ case State::kState4:
838
+ Construct(&prior.current_promise,
839
+ std::move(other.prior.current_promise));
840
+ goto tail4;
841
+ case State::kState5:
842
+ Construct(&current_promise, std::move(other.current_promise));
843
+ return;
844
+ }
845
+ tail0:
846
+ Construct(&prior.prior.prior.prior.prior.next_factory,
847
+ std::move(other.prior.prior.prior.prior.prior.next_factory));
848
+ tail1:
849
+ Construct(&prior.prior.prior.prior.next_factory,
850
+ std::move(other.prior.prior.prior.prior.next_factory));
851
+ tail2:
852
+ Construct(&prior.prior.prior.next_factory,
853
+ std::move(other.prior.prior.prior.next_factory));
854
+ tail3:
855
+ Construct(&prior.prior.next_factory,
856
+ std::move(other.prior.prior.next_factory));
857
+ tail4:
858
+ Construct(&prior.next_factory, std::move(other.prior.next_factory));
859
+ }
860
+ SeqState& operator=(SeqState&& other) = delete;
861
+ Poll<Result> PollOnce() {
862
+ switch (state) {
863
+ case State::kState0: {
864
+ auto result = prior.prior.prior.prior.prior.current_promise();
865
+ PromiseResult0* p = result.value_if_ready();
866
+ if (p == nullptr) return Pending{};
867
+ if (!PromiseResultTraits0::IsOk(*p)) {
868
+ return PromiseResultTraits0::template ReturnValue<Result>(
869
+ std::move(*p));
870
+ }
871
+ Destruct(&prior.prior.prior.prior.prior.current_promise);
872
+ auto next_promise = PromiseResultTraits0::CallFactory(
873
+ &prior.prior.prior.prior.prior.next_factory, std::move(*p));
874
+ Destruct(&prior.prior.prior.prior.prior.next_factory);
875
+ Construct(&prior.prior.prior.prior.current_promise,
876
+ std::move(next_promise));
877
+ state = State::kState1;
878
+ }
879
+ ABSL_FALLTHROUGH_INTENDED;
880
+ case State::kState1: {
881
+ auto result = prior.prior.prior.prior.current_promise();
882
+ PromiseResult1* p = result.value_if_ready();
883
+ if (p == nullptr) return Pending{};
884
+ if (!PromiseResultTraits1::IsOk(*p)) {
885
+ return PromiseResultTraits1::template ReturnValue<Result>(
886
+ std::move(*p));
887
+ }
888
+ Destruct(&prior.prior.prior.prior.current_promise);
889
+ auto next_promise = PromiseResultTraits1::CallFactory(
890
+ &prior.prior.prior.prior.next_factory, std::move(*p));
891
+ Destruct(&prior.prior.prior.prior.next_factory);
892
+ Construct(&prior.prior.prior.current_promise, std::move(next_promise));
893
+ state = State::kState2;
894
+ }
895
+ ABSL_FALLTHROUGH_INTENDED;
896
+ case State::kState2: {
897
+ auto result = prior.prior.prior.current_promise();
898
+ PromiseResult2* p = result.value_if_ready();
899
+ if (p == nullptr) return Pending{};
900
+ if (!PromiseResultTraits2::IsOk(*p)) {
901
+ return PromiseResultTraits2::template ReturnValue<Result>(
902
+ std::move(*p));
903
+ }
904
+ Destruct(&prior.prior.prior.current_promise);
905
+ auto next_promise = PromiseResultTraits2::CallFactory(
906
+ &prior.prior.prior.next_factory, std::move(*p));
907
+ Destruct(&prior.prior.prior.next_factory);
908
+ Construct(&prior.prior.current_promise, std::move(next_promise));
909
+ state = State::kState3;
910
+ }
911
+ ABSL_FALLTHROUGH_INTENDED;
912
+ case State::kState3: {
913
+ auto result = prior.prior.current_promise();
914
+ PromiseResult3* p = result.value_if_ready();
915
+ if (p == nullptr) return Pending{};
916
+ if (!PromiseResultTraits3::IsOk(*p)) {
917
+ return PromiseResultTraits3::template ReturnValue<Result>(
918
+ std::move(*p));
919
+ }
920
+ Destruct(&prior.prior.current_promise);
921
+ auto next_promise = PromiseResultTraits3::CallFactory(
922
+ &prior.prior.next_factory, std::move(*p));
923
+ Destruct(&prior.prior.next_factory);
924
+ Construct(&prior.current_promise, std::move(next_promise));
925
+ state = State::kState4;
926
+ }
927
+ ABSL_FALLTHROUGH_INTENDED;
928
+ case State::kState4: {
929
+ auto result = prior.current_promise();
930
+ PromiseResult4* p = result.value_if_ready();
931
+ if (p == nullptr) return Pending{};
932
+ if (!PromiseResultTraits4::IsOk(*p)) {
933
+ return PromiseResultTraits4::template ReturnValue<Result>(
934
+ std::move(*p));
935
+ }
936
+ Destruct(&prior.current_promise);
937
+ auto next_promise = PromiseResultTraits4::CallFactory(
938
+ &prior.next_factory, std::move(*p));
939
+ Destruct(&prior.next_factory);
940
+ Construct(&current_promise, std::move(next_promise));
941
+ state = State::kState5;
942
+ }
943
+ ABSL_FALLTHROUGH_INTENDED;
944
+ default:
945
+ case State::kState5: {
946
+ auto result = current_promise();
947
+ auto* p = result.value_if_ready();
948
+ if (p == nullptr) return Pending{};
949
+ return Result(std::move(*p));
950
+ }
951
+ }
952
+ }
953
+ };
954
+
955
+ template <template <typename> class Traits, typename P, typename F0,
956
+ typename F1, typename F2, typename F3, typename F4, typename F5>
957
+ struct SeqState<Traits, P, F0, F1, F2, F3, F4, F5> {
958
+ using Promise0 = PromiseLike<P>;
959
+ using PromiseResult0 = typename Promise0::Result;
960
+ using PromiseResultTraits0 = Traits<PromiseResult0>;
961
+ using NextFactory0 =
962
+ OncePromiseFactory<typename PromiseResultTraits0::UnwrappedType, F0>;
963
+ using Promise1 = typename NextFactory0::Promise;
964
+ using PromiseResult1 = typename Promise1::Result;
965
+ using PromiseResultTraits1 = Traits<PromiseResult1>;
966
+ using NextFactory1 =
967
+ OncePromiseFactory<typename PromiseResultTraits1::UnwrappedType, F1>;
968
+ using Promise2 = typename NextFactory1::Promise;
969
+ using PromiseResult2 = typename Promise2::Result;
970
+ using PromiseResultTraits2 = Traits<PromiseResult2>;
971
+ using NextFactory2 =
972
+ OncePromiseFactory<typename PromiseResultTraits2::UnwrappedType, F2>;
973
+ using Promise3 = typename NextFactory2::Promise;
974
+ using PromiseResult3 = typename Promise3::Result;
975
+ using PromiseResultTraits3 = Traits<PromiseResult3>;
976
+ using NextFactory3 =
977
+ OncePromiseFactory<typename PromiseResultTraits3::UnwrappedType, F3>;
978
+ using Promise4 = typename NextFactory3::Promise;
979
+ using PromiseResult4 = typename Promise4::Result;
980
+ using PromiseResultTraits4 = Traits<PromiseResult4>;
981
+ using NextFactory4 =
982
+ OncePromiseFactory<typename PromiseResultTraits4::UnwrappedType, F4>;
983
+ using Promise5 = typename NextFactory4::Promise;
984
+ using PromiseResult5 = typename Promise5::Result;
985
+ using PromiseResultTraits5 = Traits<PromiseResult5>;
986
+ using NextFactory5 =
987
+ OncePromiseFactory<typename PromiseResultTraits5::UnwrappedType, F5>;
988
+ using Promise6 = typename NextFactory5::Promise;
989
+ using PromiseResult6 = typename Promise6::Result;
990
+ using PromiseResultTraits6 = Traits<PromiseResult6>;
991
+ using Result = typename PromiseResultTraits6::WrappedType;
992
+ struct Running0 {
993
+ GPR_NO_UNIQUE_ADDRESS Promise0 current_promise;
994
+ GPR_NO_UNIQUE_ADDRESS NextFactory0 next_factory;
995
+ };
996
+ struct Running1 {
997
+ union {
998
+ GPR_NO_UNIQUE_ADDRESS Running0 prior;
999
+ GPR_NO_UNIQUE_ADDRESS Promise1 current_promise;
1000
+ };
1001
+ GPR_NO_UNIQUE_ADDRESS NextFactory1 next_factory;
1002
+ };
1003
+ struct Running2 {
1004
+ union {
1005
+ GPR_NO_UNIQUE_ADDRESS Running1 prior;
1006
+ GPR_NO_UNIQUE_ADDRESS Promise2 current_promise;
1007
+ };
1008
+ GPR_NO_UNIQUE_ADDRESS NextFactory2 next_factory;
1009
+ };
1010
+ struct Running3 {
1011
+ union {
1012
+ GPR_NO_UNIQUE_ADDRESS Running2 prior;
1013
+ GPR_NO_UNIQUE_ADDRESS Promise3 current_promise;
1014
+ };
1015
+ GPR_NO_UNIQUE_ADDRESS NextFactory3 next_factory;
1016
+ };
1017
+ struct Running4 {
1018
+ union {
1019
+ GPR_NO_UNIQUE_ADDRESS Running3 prior;
1020
+ GPR_NO_UNIQUE_ADDRESS Promise4 current_promise;
1021
+ };
1022
+ GPR_NO_UNIQUE_ADDRESS NextFactory4 next_factory;
1023
+ };
1024
+ struct Running5 {
1025
+ union {
1026
+ GPR_NO_UNIQUE_ADDRESS Running4 prior;
1027
+ GPR_NO_UNIQUE_ADDRESS Promise5 current_promise;
1028
+ };
1029
+ GPR_NO_UNIQUE_ADDRESS NextFactory5 next_factory;
1030
+ };
1031
+ union {
1032
+ GPR_NO_UNIQUE_ADDRESS Running5 prior;
1033
+ GPR_NO_UNIQUE_ADDRESS Promise6 current_promise;
1034
+ };
1035
+ enum class State : uint8_t {
1036
+ kState0,
1037
+ kState1,
1038
+ kState2,
1039
+ kState3,
1040
+ kState4,
1041
+ kState5,
1042
+ kState6
1043
+ };
1044
+ GPR_NO_UNIQUE_ADDRESS State state = State::kState0;
1045
+
1046
+ SeqState(P&& p, F0&& f0, F1&& f1, F2&& f2, F3&& f3, F4&& f4,
1047
+ F5&& f5) noexcept {
1048
+ Construct(&prior.prior.prior.prior.prior.prior.current_promise,
1049
+ std::forward<P>(p));
1050
+ Construct(&prior.prior.prior.prior.prior.prior.next_factory,
1051
+ std::forward<F0>(f0));
1052
+ Construct(&prior.prior.prior.prior.prior.next_factory,
1053
+ std::forward<F1>(f1));
1054
+ Construct(&prior.prior.prior.prior.next_factory, std::forward<F2>(f2));
1055
+ Construct(&prior.prior.prior.next_factory, std::forward<F3>(f3));
1056
+ Construct(&prior.prior.next_factory, std::forward<F4>(f4));
1057
+ Construct(&prior.next_factory, std::forward<F5>(f5));
1058
+ }
1059
+ ~SeqState() {
1060
+ switch (state) {
1061
+ case State::kState0:
1062
+ Destruct(&prior.prior.prior.prior.prior.prior.current_promise);
1063
+ goto tail0;
1064
+ case State::kState1:
1065
+ Destruct(&prior.prior.prior.prior.prior.current_promise);
1066
+ goto tail1;
1067
+ case State::kState2:
1068
+ Destruct(&prior.prior.prior.prior.current_promise);
1069
+ goto tail2;
1070
+ case State::kState3:
1071
+ Destruct(&prior.prior.prior.current_promise);
1072
+ goto tail3;
1073
+ case State::kState4:
1074
+ Destruct(&prior.prior.current_promise);
1075
+ goto tail4;
1076
+ case State::kState5:
1077
+ Destruct(&prior.current_promise);
1078
+ goto tail5;
1079
+ case State::kState6:
1080
+ Destruct(&current_promise);
1081
+ return;
1082
+ }
1083
+ tail0:
1084
+ Destruct(&prior.prior.prior.prior.prior.prior.next_factory);
1085
+ tail1:
1086
+ Destruct(&prior.prior.prior.prior.prior.next_factory);
1087
+ tail2:
1088
+ Destruct(&prior.prior.prior.prior.next_factory);
1089
+ tail3:
1090
+ Destruct(&prior.prior.prior.next_factory);
1091
+ tail4:
1092
+ Destruct(&prior.prior.next_factory);
1093
+ tail5:
1094
+ Destruct(&prior.next_factory);
1095
+ }
1096
+ SeqState(const SeqState& other) noexcept : state(other.state) {
1097
+ GPR_ASSERT(state == State::kState0);
1098
+ Construct(&prior.current_promise, other.prior.current_promise);
1099
+ Construct(&prior.prior.prior.prior.prior.prior.next_factory,
1100
+ other.prior.prior.prior.prior.prior.prior.next_factory);
1101
+ Construct(&prior.prior.prior.prior.prior.next_factory,
1102
+ other.prior.prior.prior.prior.prior.next_factory);
1103
+ Construct(&prior.prior.prior.prior.next_factory,
1104
+ other.prior.prior.prior.prior.next_factory);
1105
+ Construct(&prior.prior.prior.next_factory,
1106
+ other.prior.prior.prior.next_factory);
1107
+ Construct(&prior.prior.next_factory, other.prior.prior.next_factory);
1108
+ Construct(&prior.next_factory, other.prior.next_factory);
1109
+ }
1110
+ SeqState& operator=(const SeqState& other) = delete;
1111
+ SeqState(SeqState&& other) noexcept : state(other.state) {
1112
+ switch (state) {
1113
+ case State::kState0:
1114
+ Construct(
1115
+ &prior.prior.prior.prior.prior.prior.current_promise,
1116
+ std::move(
1117
+ other.prior.prior.prior.prior.prior.prior.current_promise));
1118
+ goto tail0;
1119
+ case State::kState1:
1120
+ Construct(
1121
+ &prior.prior.prior.prior.prior.current_promise,
1122
+ std::move(other.prior.prior.prior.prior.prior.current_promise));
1123
+ goto tail1;
1124
+ case State::kState2:
1125
+ Construct(&prior.prior.prior.prior.current_promise,
1126
+ std::move(other.prior.prior.prior.prior.current_promise));
1127
+ goto tail2;
1128
+ case State::kState3:
1129
+ Construct(&prior.prior.prior.current_promise,
1130
+ std::move(other.prior.prior.prior.current_promise));
1131
+ goto tail3;
1132
+ case State::kState4:
1133
+ Construct(&prior.prior.current_promise,
1134
+ std::move(other.prior.prior.current_promise));
1135
+ goto tail4;
1136
+ case State::kState5:
1137
+ Construct(&prior.current_promise,
1138
+ std::move(other.prior.current_promise));
1139
+ goto tail5;
1140
+ case State::kState6:
1141
+ Construct(&current_promise, std::move(other.current_promise));
1142
+ return;
1143
+ }
1144
+ tail0:
1145
+ Construct(
1146
+ &prior.prior.prior.prior.prior.prior.next_factory,
1147
+ std::move(other.prior.prior.prior.prior.prior.prior.next_factory));
1148
+ tail1:
1149
+ Construct(&prior.prior.prior.prior.prior.next_factory,
1150
+ std::move(other.prior.prior.prior.prior.prior.next_factory));
1151
+ tail2:
1152
+ Construct(&prior.prior.prior.prior.next_factory,
1153
+ std::move(other.prior.prior.prior.prior.next_factory));
1154
+ tail3:
1155
+ Construct(&prior.prior.prior.next_factory,
1156
+ std::move(other.prior.prior.prior.next_factory));
1157
+ tail4:
1158
+ Construct(&prior.prior.next_factory,
1159
+ std::move(other.prior.prior.next_factory));
1160
+ tail5:
1161
+ Construct(&prior.next_factory, std::move(other.prior.next_factory));
1162
+ }
1163
+ SeqState& operator=(SeqState&& other) = delete;
1164
+ Poll<Result> PollOnce() {
1165
+ switch (state) {
1166
+ case State::kState0: {
1167
+ auto result = prior.prior.prior.prior.prior.prior.current_promise();
1168
+ PromiseResult0* p = result.value_if_ready();
1169
+ if (p == nullptr) return Pending{};
1170
+ if (!PromiseResultTraits0::IsOk(*p)) {
1171
+ return PromiseResultTraits0::template ReturnValue<Result>(
1172
+ std::move(*p));
1173
+ }
1174
+ Destruct(&prior.prior.prior.prior.prior.prior.current_promise);
1175
+ auto next_promise = PromiseResultTraits0::CallFactory(
1176
+ &prior.prior.prior.prior.prior.prior.next_factory, std::move(*p));
1177
+ Destruct(&prior.prior.prior.prior.prior.prior.next_factory);
1178
+ Construct(&prior.prior.prior.prior.prior.current_promise,
1179
+ std::move(next_promise));
1180
+ state = State::kState1;
1181
+ }
1182
+ ABSL_FALLTHROUGH_INTENDED;
1183
+ case State::kState1: {
1184
+ auto result = prior.prior.prior.prior.prior.current_promise();
1185
+ PromiseResult1* p = result.value_if_ready();
1186
+ if (p == nullptr) return Pending{};
1187
+ if (!PromiseResultTraits1::IsOk(*p)) {
1188
+ return PromiseResultTraits1::template ReturnValue<Result>(
1189
+ std::move(*p));
1190
+ }
1191
+ Destruct(&prior.prior.prior.prior.prior.current_promise);
1192
+ auto next_promise = PromiseResultTraits1::CallFactory(
1193
+ &prior.prior.prior.prior.prior.next_factory, std::move(*p));
1194
+ Destruct(&prior.prior.prior.prior.prior.next_factory);
1195
+ Construct(&prior.prior.prior.prior.current_promise,
1196
+ std::move(next_promise));
1197
+ state = State::kState2;
1198
+ }
1199
+ ABSL_FALLTHROUGH_INTENDED;
1200
+ case State::kState2: {
1201
+ auto result = prior.prior.prior.prior.current_promise();
1202
+ PromiseResult2* p = result.value_if_ready();
1203
+ if (p == nullptr) return Pending{};
1204
+ if (!PromiseResultTraits2::IsOk(*p)) {
1205
+ return PromiseResultTraits2::template ReturnValue<Result>(
1206
+ std::move(*p));
1207
+ }
1208
+ Destruct(&prior.prior.prior.prior.current_promise);
1209
+ auto next_promise = PromiseResultTraits2::CallFactory(
1210
+ &prior.prior.prior.prior.next_factory, std::move(*p));
1211
+ Destruct(&prior.prior.prior.prior.next_factory);
1212
+ Construct(&prior.prior.prior.current_promise, std::move(next_promise));
1213
+ state = State::kState3;
1214
+ }
1215
+ ABSL_FALLTHROUGH_INTENDED;
1216
+ case State::kState3: {
1217
+ auto result = prior.prior.prior.current_promise();
1218
+ PromiseResult3* p = result.value_if_ready();
1219
+ if (p == nullptr) return Pending{};
1220
+ if (!PromiseResultTraits3::IsOk(*p)) {
1221
+ return PromiseResultTraits3::template ReturnValue<Result>(
1222
+ std::move(*p));
1223
+ }
1224
+ Destruct(&prior.prior.prior.current_promise);
1225
+ auto next_promise = PromiseResultTraits3::CallFactory(
1226
+ &prior.prior.prior.next_factory, std::move(*p));
1227
+ Destruct(&prior.prior.prior.next_factory);
1228
+ Construct(&prior.prior.current_promise, std::move(next_promise));
1229
+ state = State::kState4;
1230
+ }
1231
+ ABSL_FALLTHROUGH_INTENDED;
1232
+ case State::kState4: {
1233
+ auto result = prior.prior.current_promise();
1234
+ PromiseResult4* p = result.value_if_ready();
1235
+ if (p == nullptr) return Pending{};
1236
+ if (!PromiseResultTraits4::IsOk(*p)) {
1237
+ return PromiseResultTraits4::template ReturnValue<Result>(
1238
+ std::move(*p));
1239
+ }
1240
+ Destruct(&prior.prior.current_promise);
1241
+ auto next_promise = PromiseResultTraits4::CallFactory(
1242
+ &prior.prior.next_factory, std::move(*p));
1243
+ Destruct(&prior.prior.next_factory);
1244
+ Construct(&prior.current_promise, std::move(next_promise));
1245
+ state = State::kState5;
1246
+ }
1247
+ ABSL_FALLTHROUGH_INTENDED;
1248
+ case State::kState5: {
1249
+ auto result = prior.current_promise();
1250
+ PromiseResult5* p = result.value_if_ready();
1251
+ if (p == nullptr) return Pending{};
1252
+ if (!PromiseResultTraits5::IsOk(*p)) {
1253
+ return PromiseResultTraits5::template ReturnValue<Result>(
1254
+ std::move(*p));
1255
+ }
1256
+ Destruct(&prior.current_promise);
1257
+ auto next_promise = PromiseResultTraits5::CallFactory(
1258
+ &prior.next_factory, std::move(*p));
1259
+ Destruct(&prior.next_factory);
1260
+ Construct(&current_promise, std::move(next_promise));
1261
+ state = State::kState6;
1262
+ }
1263
+ ABSL_FALLTHROUGH_INTENDED;
1264
+ default:
1265
+ case State::kState6: {
1266
+ auto result = current_promise();
1267
+ auto* p = result.value_if_ready();
1268
+ if (p == nullptr) return Pending{};
1269
+ return Result(std::move(*p));
1270
+ }
1271
+ }
1272
+ }
1273
+ };
1274
+
1275
+ template <template <typename> class Traits, typename P, typename F0,
1276
+ typename F1, typename F2, typename F3, typename F4, typename F5,
1277
+ typename F6>
1278
+ struct SeqState<Traits, P, F0, F1, F2, F3, F4, F5, F6> {
1279
+ using Promise0 = PromiseLike<P>;
1280
+ using PromiseResult0 = typename Promise0::Result;
1281
+ using PromiseResultTraits0 = Traits<PromiseResult0>;
1282
+ using NextFactory0 =
1283
+ OncePromiseFactory<typename PromiseResultTraits0::UnwrappedType, F0>;
1284
+ using Promise1 = typename NextFactory0::Promise;
1285
+ using PromiseResult1 = typename Promise1::Result;
1286
+ using PromiseResultTraits1 = Traits<PromiseResult1>;
1287
+ using NextFactory1 =
1288
+ OncePromiseFactory<typename PromiseResultTraits1::UnwrappedType, F1>;
1289
+ using Promise2 = typename NextFactory1::Promise;
1290
+ using PromiseResult2 = typename Promise2::Result;
1291
+ using PromiseResultTraits2 = Traits<PromiseResult2>;
1292
+ using NextFactory2 =
1293
+ OncePromiseFactory<typename PromiseResultTraits2::UnwrappedType, F2>;
1294
+ using Promise3 = typename NextFactory2::Promise;
1295
+ using PromiseResult3 = typename Promise3::Result;
1296
+ using PromiseResultTraits3 = Traits<PromiseResult3>;
1297
+ using NextFactory3 =
1298
+ OncePromiseFactory<typename PromiseResultTraits3::UnwrappedType, F3>;
1299
+ using Promise4 = typename NextFactory3::Promise;
1300
+ using PromiseResult4 = typename Promise4::Result;
1301
+ using PromiseResultTraits4 = Traits<PromiseResult4>;
1302
+ using NextFactory4 =
1303
+ OncePromiseFactory<typename PromiseResultTraits4::UnwrappedType, F4>;
1304
+ using Promise5 = typename NextFactory4::Promise;
1305
+ using PromiseResult5 = typename Promise5::Result;
1306
+ using PromiseResultTraits5 = Traits<PromiseResult5>;
1307
+ using NextFactory5 =
1308
+ OncePromiseFactory<typename PromiseResultTraits5::UnwrappedType, F5>;
1309
+ using Promise6 = typename NextFactory5::Promise;
1310
+ using PromiseResult6 = typename Promise6::Result;
1311
+ using PromiseResultTraits6 = Traits<PromiseResult6>;
1312
+ using NextFactory6 =
1313
+ OncePromiseFactory<typename PromiseResultTraits6::UnwrappedType, F6>;
1314
+ using Promise7 = typename NextFactory6::Promise;
1315
+ using PromiseResult7 = typename Promise7::Result;
1316
+ using PromiseResultTraits7 = Traits<PromiseResult7>;
1317
+ using Result = typename PromiseResultTraits7::WrappedType;
1318
+ struct Running0 {
1319
+ GPR_NO_UNIQUE_ADDRESS Promise0 current_promise;
1320
+ GPR_NO_UNIQUE_ADDRESS NextFactory0 next_factory;
1321
+ };
1322
+ struct Running1 {
1323
+ union {
1324
+ GPR_NO_UNIQUE_ADDRESS Running0 prior;
1325
+ GPR_NO_UNIQUE_ADDRESS Promise1 current_promise;
1326
+ };
1327
+ GPR_NO_UNIQUE_ADDRESS NextFactory1 next_factory;
1328
+ };
1329
+ struct Running2 {
1330
+ union {
1331
+ GPR_NO_UNIQUE_ADDRESS Running1 prior;
1332
+ GPR_NO_UNIQUE_ADDRESS Promise2 current_promise;
1333
+ };
1334
+ GPR_NO_UNIQUE_ADDRESS NextFactory2 next_factory;
1335
+ };
1336
+ struct Running3 {
1337
+ union {
1338
+ GPR_NO_UNIQUE_ADDRESS Running2 prior;
1339
+ GPR_NO_UNIQUE_ADDRESS Promise3 current_promise;
1340
+ };
1341
+ GPR_NO_UNIQUE_ADDRESS NextFactory3 next_factory;
1342
+ };
1343
+ struct Running4 {
1344
+ union {
1345
+ GPR_NO_UNIQUE_ADDRESS Running3 prior;
1346
+ GPR_NO_UNIQUE_ADDRESS Promise4 current_promise;
1347
+ };
1348
+ GPR_NO_UNIQUE_ADDRESS NextFactory4 next_factory;
1349
+ };
1350
+ struct Running5 {
1351
+ union {
1352
+ GPR_NO_UNIQUE_ADDRESS Running4 prior;
1353
+ GPR_NO_UNIQUE_ADDRESS Promise5 current_promise;
1354
+ };
1355
+ GPR_NO_UNIQUE_ADDRESS NextFactory5 next_factory;
1356
+ };
1357
+ struct Running6 {
1358
+ union {
1359
+ GPR_NO_UNIQUE_ADDRESS Running5 prior;
1360
+ GPR_NO_UNIQUE_ADDRESS Promise6 current_promise;
1361
+ };
1362
+ GPR_NO_UNIQUE_ADDRESS NextFactory6 next_factory;
1363
+ };
1364
+ union {
1365
+ GPR_NO_UNIQUE_ADDRESS Running6 prior;
1366
+ GPR_NO_UNIQUE_ADDRESS Promise7 current_promise;
1367
+ };
1368
+ enum class State : uint8_t {
1369
+ kState0,
1370
+ kState1,
1371
+ kState2,
1372
+ kState3,
1373
+ kState4,
1374
+ kState5,
1375
+ kState6,
1376
+ kState7
1377
+ };
1378
+ GPR_NO_UNIQUE_ADDRESS State state = State::kState0;
1379
+
1380
+ SeqState(P&& p, F0&& f0, F1&& f1, F2&& f2, F3&& f3, F4&& f4, F5&& f5,
1381
+ F6&& f6) noexcept {
1382
+ Construct(&prior.prior.prior.prior.prior.prior.prior.current_promise,
1383
+ std::forward<P>(p));
1384
+ Construct(&prior.prior.prior.prior.prior.prior.prior.next_factory,
1385
+ std::forward<F0>(f0));
1386
+ Construct(&prior.prior.prior.prior.prior.prior.next_factory,
1387
+ std::forward<F1>(f1));
1388
+ Construct(&prior.prior.prior.prior.prior.next_factory,
1389
+ std::forward<F2>(f2));
1390
+ Construct(&prior.prior.prior.prior.next_factory, std::forward<F3>(f3));
1391
+ Construct(&prior.prior.prior.next_factory, std::forward<F4>(f4));
1392
+ Construct(&prior.prior.next_factory, std::forward<F5>(f5));
1393
+ Construct(&prior.next_factory, std::forward<F6>(f6));
1394
+ }
1395
+ ~SeqState() {
1396
+ switch (state) {
1397
+ case State::kState0:
1398
+ Destruct(&prior.prior.prior.prior.prior.prior.prior.current_promise);
1399
+ goto tail0;
1400
+ case State::kState1:
1401
+ Destruct(&prior.prior.prior.prior.prior.prior.current_promise);
1402
+ goto tail1;
1403
+ case State::kState2:
1404
+ Destruct(&prior.prior.prior.prior.prior.current_promise);
1405
+ goto tail2;
1406
+ case State::kState3:
1407
+ Destruct(&prior.prior.prior.prior.current_promise);
1408
+ goto tail3;
1409
+ case State::kState4:
1410
+ Destruct(&prior.prior.prior.current_promise);
1411
+ goto tail4;
1412
+ case State::kState5:
1413
+ Destruct(&prior.prior.current_promise);
1414
+ goto tail5;
1415
+ case State::kState6:
1416
+ Destruct(&prior.current_promise);
1417
+ goto tail6;
1418
+ case State::kState7:
1419
+ Destruct(&current_promise);
1420
+ return;
1421
+ }
1422
+ tail0:
1423
+ Destruct(&prior.prior.prior.prior.prior.prior.prior.next_factory);
1424
+ tail1:
1425
+ Destruct(&prior.prior.prior.prior.prior.prior.next_factory);
1426
+ tail2:
1427
+ Destruct(&prior.prior.prior.prior.prior.next_factory);
1428
+ tail3:
1429
+ Destruct(&prior.prior.prior.prior.next_factory);
1430
+ tail4:
1431
+ Destruct(&prior.prior.prior.next_factory);
1432
+ tail5:
1433
+ Destruct(&prior.prior.next_factory);
1434
+ tail6:
1435
+ Destruct(&prior.next_factory);
1436
+ }
1437
+ SeqState(const SeqState& other) noexcept : state(other.state) {
1438
+ GPR_ASSERT(state == State::kState0);
1439
+ Construct(&prior.current_promise, other.prior.current_promise);
1440
+ Construct(&prior.prior.prior.prior.prior.prior.prior.next_factory,
1441
+ other.prior.prior.prior.prior.prior.prior.prior.next_factory);
1442
+ Construct(&prior.prior.prior.prior.prior.prior.next_factory,
1443
+ other.prior.prior.prior.prior.prior.prior.next_factory);
1444
+ Construct(&prior.prior.prior.prior.prior.next_factory,
1445
+ other.prior.prior.prior.prior.prior.next_factory);
1446
+ Construct(&prior.prior.prior.prior.next_factory,
1447
+ other.prior.prior.prior.prior.next_factory);
1448
+ Construct(&prior.prior.prior.next_factory,
1449
+ other.prior.prior.prior.next_factory);
1450
+ Construct(&prior.prior.next_factory, other.prior.prior.next_factory);
1451
+ Construct(&prior.next_factory, other.prior.next_factory);
1452
+ }
1453
+ SeqState& operator=(const SeqState& other) = delete;
1454
+ SeqState(SeqState&& other) noexcept : state(other.state) {
1455
+ switch (state) {
1456
+ case State::kState0:
1457
+ Construct(&prior.prior.prior.prior.prior.prior.prior.current_promise,
1458
+ std::move(other.prior.prior.prior.prior.prior.prior.prior
1459
+ .current_promise));
1460
+ goto tail0;
1461
+ case State::kState1:
1462
+ Construct(
1463
+ &prior.prior.prior.prior.prior.prior.current_promise,
1464
+ std::move(
1465
+ other.prior.prior.prior.prior.prior.prior.current_promise));
1466
+ goto tail1;
1467
+ case State::kState2:
1468
+ Construct(
1469
+ &prior.prior.prior.prior.prior.current_promise,
1470
+ std::move(other.prior.prior.prior.prior.prior.current_promise));
1471
+ goto tail2;
1472
+ case State::kState3:
1473
+ Construct(&prior.prior.prior.prior.current_promise,
1474
+ std::move(other.prior.prior.prior.prior.current_promise));
1475
+ goto tail3;
1476
+ case State::kState4:
1477
+ Construct(&prior.prior.prior.current_promise,
1478
+ std::move(other.prior.prior.prior.current_promise));
1479
+ goto tail4;
1480
+ case State::kState5:
1481
+ Construct(&prior.prior.current_promise,
1482
+ std::move(other.prior.prior.current_promise));
1483
+ goto tail5;
1484
+ case State::kState6:
1485
+ Construct(&prior.current_promise,
1486
+ std::move(other.prior.current_promise));
1487
+ goto tail6;
1488
+ case State::kState7:
1489
+ Construct(&current_promise, std::move(other.current_promise));
1490
+ return;
1491
+ }
1492
+ tail0:
1493
+ Construct(
1494
+ &prior.prior.prior.prior.prior.prior.prior.next_factory,
1495
+ std::move(
1496
+ other.prior.prior.prior.prior.prior.prior.prior.next_factory));
1497
+ tail1:
1498
+ Construct(
1499
+ &prior.prior.prior.prior.prior.prior.next_factory,
1500
+ std::move(other.prior.prior.prior.prior.prior.prior.next_factory));
1501
+ tail2:
1502
+ Construct(&prior.prior.prior.prior.prior.next_factory,
1503
+ std::move(other.prior.prior.prior.prior.prior.next_factory));
1504
+ tail3:
1505
+ Construct(&prior.prior.prior.prior.next_factory,
1506
+ std::move(other.prior.prior.prior.prior.next_factory));
1507
+ tail4:
1508
+ Construct(&prior.prior.prior.next_factory,
1509
+ std::move(other.prior.prior.prior.next_factory));
1510
+ tail5:
1511
+ Construct(&prior.prior.next_factory,
1512
+ std::move(other.prior.prior.next_factory));
1513
+ tail6:
1514
+ Construct(&prior.next_factory, std::move(other.prior.next_factory));
1515
+ }
1516
+ SeqState& operator=(SeqState&& other) = delete;
1517
+ Poll<Result> PollOnce() {
1518
+ switch (state) {
1519
+ case State::kState0: {
1520
+ auto result =
1521
+ prior.prior.prior.prior.prior.prior.prior.current_promise();
1522
+ PromiseResult0* p = result.value_if_ready();
1523
+ if (p == nullptr) return Pending{};
1524
+ if (!PromiseResultTraits0::IsOk(*p)) {
1525
+ return PromiseResultTraits0::template ReturnValue<Result>(
1526
+ std::move(*p));
1527
+ }
1528
+ Destruct(&prior.prior.prior.prior.prior.prior.prior.current_promise);
1529
+ auto next_promise = PromiseResultTraits0::CallFactory(
1530
+ &prior.prior.prior.prior.prior.prior.prior.next_factory,
1531
+ std::move(*p));
1532
+ Destruct(&prior.prior.prior.prior.prior.prior.prior.next_factory);
1533
+ Construct(&prior.prior.prior.prior.prior.prior.current_promise,
1534
+ std::move(next_promise));
1535
+ state = State::kState1;
1536
+ }
1537
+ ABSL_FALLTHROUGH_INTENDED;
1538
+ case State::kState1: {
1539
+ auto result = prior.prior.prior.prior.prior.prior.current_promise();
1540
+ PromiseResult1* p = result.value_if_ready();
1541
+ if (p == nullptr) return Pending{};
1542
+ if (!PromiseResultTraits1::IsOk(*p)) {
1543
+ return PromiseResultTraits1::template ReturnValue<Result>(
1544
+ std::move(*p));
1545
+ }
1546
+ Destruct(&prior.prior.prior.prior.prior.prior.current_promise);
1547
+ auto next_promise = PromiseResultTraits1::CallFactory(
1548
+ &prior.prior.prior.prior.prior.prior.next_factory, std::move(*p));
1549
+ Destruct(&prior.prior.prior.prior.prior.prior.next_factory);
1550
+ Construct(&prior.prior.prior.prior.prior.current_promise,
1551
+ std::move(next_promise));
1552
+ state = State::kState2;
1553
+ }
1554
+ ABSL_FALLTHROUGH_INTENDED;
1555
+ case State::kState2: {
1556
+ auto result = prior.prior.prior.prior.prior.current_promise();
1557
+ PromiseResult2* p = result.value_if_ready();
1558
+ if (p == nullptr) return Pending{};
1559
+ if (!PromiseResultTraits2::IsOk(*p)) {
1560
+ return PromiseResultTraits2::template ReturnValue<Result>(
1561
+ std::move(*p));
1562
+ }
1563
+ Destruct(&prior.prior.prior.prior.prior.current_promise);
1564
+ auto next_promise = PromiseResultTraits2::CallFactory(
1565
+ &prior.prior.prior.prior.prior.next_factory, std::move(*p));
1566
+ Destruct(&prior.prior.prior.prior.prior.next_factory);
1567
+ Construct(&prior.prior.prior.prior.current_promise,
1568
+ std::move(next_promise));
1569
+ state = State::kState3;
1570
+ }
1571
+ ABSL_FALLTHROUGH_INTENDED;
1572
+ case State::kState3: {
1573
+ auto result = prior.prior.prior.prior.current_promise();
1574
+ PromiseResult3* p = result.value_if_ready();
1575
+ if (p == nullptr) return Pending{};
1576
+ if (!PromiseResultTraits3::IsOk(*p)) {
1577
+ return PromiseResultTraits3::template ReturnValue<Result>(
1578
+ std::move(*p));
1579
+ }
1580
+ Destruct(&prior.prior.prior.prior.current_promise);
1581
+ auto next_promise = PromiseResultTraits3::CallFactory(
1582
+ &prior.prior.prior.prior.next_factory, std::move(*p));
1583
+ Destruct(&prior.prior.prior.prior.next_factory);
1584
+ Construct(&prior.prior.prior.current_promise, std::move(next_promise));
1585
+ state = State::kState4;
1586
+ }
1587
+ ABSL_FALLTHROUGH_INTENDED;
1588
+ case State::kState4: {
1589
+ auto result = prior.prior.prior.current_promise();
1590
+ PromiseResult4* p = result.value_if_ready();
1591
+ if (p == nullptr) return Pending{};
1592
+ if (!PromiseResultTraits4::IsOk(*p)) {
1593
+ return PromiseResultTraits4::template ReturnValue<Result>(
1594
+ std::move(*p));
1595
+ }
1596
+ Destruct(&prior.prior.prior.current_promise);
1597
+ auto next_promise = PromiseResultTraits4::CallFactory(
1598
+ &prior.prior.prior.next_factory, std::move(*p));
1599
+ Destruct(&prior.prior.prior.next_factory);
1600
+ Construct(&prior.prior.current_promise, std::move(next_promise));
1601
+ state = State::kState5;
1602
+ }
1603
+ ABSL_FALLTHROUGH_INTENDED;
1604
+ case State::kState5: {
1605
+ auto result = prior.prior.current_promise();
1606
+ PromiseResult5* p = result.value_if_ready();
1607
+ if (p == nullptr) return Pending{};
1608
+ if (!PromiseResultTraits5::IsOk(*p)) {
1609
+ return PromiseResultTraits5::template ReturnValue<Result>(
1610
+ std::move(*p));
1611
+ }
1612
+ Destruct(&prior.prior.current_promise);
1613
+ auto next_promise = PromiseResultTraits5::CallFactory(
1614
+ &prior.prior.next_factory, std::move(*p));
1615
+ Destruct(&prior.prior.next_factory);
1616
+ Construct(&prior.current_promise, std::move(next_promise));
1617
+ state = State::kState6;
1618
+ }
1619
+ ABSL_FALLTHROUGH_INTENDED;
1620
+ case State::kState6: {
1621
+ auto result = prior.current_promise();
1622
+ PromiseResult6* p = result.value_if_ready();
1623
+ if (p == nullptr) return Pending{};
1624
+ if (!PromiseResultTraits6::IsOk(*p)) {
1625
+ return PromiseResultTraits6::template ReturnValue<Result>(
1626
+ std::move(*p));
1627
+ }
1628
+ Destruct(&prior.current_promise);
1629
+ auto next_promise = PromiseResultTraits6::CallFactory(
1630
+ &prior.next_factory, std::move(*p));
1631
+ Destruct(&prior.next_factory);
1632
+ Construct(&current_promise, std::move(next_promise));
1633
+ state = State::kState7;
1634
+ }
1635
+ ABSL_FALLTHROUGH_INTENDED;
1636
+ default:
1637
+ case State::kState7: {
1638
+ auto result = current_promise();
1639
+ auto* p = result.value_if_ready();
1640
+ if (p == nullptr) return Pending{};
1641
+ return Result(std::move(*p));
1642
+ }
1643
+ }
1644
+ }
1645
+ };
1646
+
1647
+ template <template <typename> class Traits, typename P, typename F0,
1648
+ typename F1, typename F2, typename F3, typename F4, typename F5,
1649
+ typename F6, typename F7>
1650
+ struct SeqState<Traits, P, F0, F1, F2, F3, F4, F5, F6, F7> {
1651
+ using Promise0 = PromiseLike<P>;
1652
+ using PromiseResult0 = typename Promise0::Result;
1653
+ using PromiseResultTraits0 = Traits<PromiseResult0>;
1654
+ using NextFactory0 =
1655
+ OncePromiseFactory<typename PromiseResultTraits0::UnwrappedType, F0>;
1656
+ using Promise1 = typename NextFactory0::Promise;
1657
+ using PromiseResult1 = typename Promise1::Result;
1658
+ using PromiseResultTraits1 = Traits<PromiseResult1>;
1659
+ using NextFactory1 =
1660
+ OncePromiseFactory<typename PromiseResultTraits1::UnwrappedType, F1>;
1661
+ using Promise2 = typename NextFactory1::Promise;
1662
+ using PromiseResult2 = typename Promise2::Result;
1663
+ using PromiseResultTraits2 = Traits<PromiseResult2>;
1664
+ using NextFactory2 =
1665
+ OncePromiseFactory<typename PromiseResultTraits2::UnwrappedType, F2>;
1666
+ using Promise3 = typename NextFactory2::Promise;
1667
+ using PromiseResult3 = typename Promise3::Result;
1668
+ using PromiseResultTraits3 = Traits<PromiseResult3>;
1669
+ using NextFactory3 =
1670
+ OncePromiseFactory<typename PromiseResultTraits3::UnwrappedType, F3>;
1671
+ using Promise4 = typename NextFactory3::Promise;
1672
+ using PromiseResult4 = typename Promise4::Result;
1673
+ using PromiseResultTraits4 = Traits<PromiseResult4>;
1674
+ using NextFactory4 =
1675
+ OncePromiseFactory<typename PromiseResultTraits4::UnwrappedType, F4>;
1676
+ using Promise5 = typename NextFactory4::Promise;
1677
+ using PromiseResult5 = typename Promise5::Result;
1678
+ using PromiseResultTraits5 = Traits<PromiseResult5>;
1679
+ using NextFactory5 =
1680
+ OncePromiseFactory<typename PromiseResultTraits5::UnwrappedType, F5>;
1681
+ using Promise6 = typename NextFactory5::Promise;
1682
+ using PromiseResult6 = typename Promise6::Result;
1683
+ using PromiseResultTraits6 = Traits<PromiseResult6>;
1684
+ using NextFactory6 =
1685
+ OncePromiseFactory<typename PromiseResultTraits6::UnwrappedType, F6>;
1686
+ using Promise7 = typename NextFactory6::Promise;
1687
+ using PromiseResult7 = typename Promise7::Result;
1688
+ using PromiseResultTraits7 = Traits<PromiseResult7>;
1689
+ using NextFactory7 =
1690
+ OncePromiseFactory<typename PromiseResultTraits7::UnwrappedType, F7>;
1691
+ using Promise8 = typename NextFactory7::Promise;
1692
+ using PromiseResult8 = typename Promise8::Result;
1693
+ using PromiseResultTraits8 = Traits<PromiseResult8>;
1694
+ using Result = typename PromiseResultTraits8::WrappedType;
1695
+ struct Running0 {
1696
+ GPR_NO_UNIQUE_ADDRESS Promise0 current_promise;
1697
+ GPR_NO_UNIQUE_ADDRESS NextFactory0 next_factory;
1698
+ };
1699
+ struct Running1 {
1700
+ union {
1701
+ GPR_NO_UNIQUE_ADDRESS Running0 prior;
1702
+ GPR_NO_UNIQUE_ADDRESS Promise1 current_promise;
1703
+ };
1704
+ GPR_NO_UNIQUE_ADDRESS NextFactory1 next_factory;
1705
+ };
1706
+ struct Running2 {
1707
+ union {
1708
+ GPR_NO_UNIQUE_ADDRESS Running1 prior;
1709
+ GPR_NO_UNIQUE_ADDRESS Promise2 current_promise;
1710
+ };
1711
+ GPR_NO_UNIQUE_ADDRESS NextFactory2 next_factory;
1712
+ };
1713
+ struct Running3 {
1714
+ union {
1715
+ GPR_NO_UNIQUE_ADDRESS Running2 prior;
1716
+ GPR_NO_UNIQUE_ADDRESS Promise3 current_promise;
1717
+ };
1718
+ GPR_NO_UNIQUE_ADDRESS NextFactory3 next_factory;
1719
+ };
1720
+ struct Running4 {
1721
+ union {
1722
+ GPR_NO_UNIQUE_ADDRESS Running3 prior;
1723
+ GPR_NO_UNIQUE_ADDRESS Promise4 current_promise;
1724
+ };
1725
+ GPR_NO_UNIQUE_ADDRESS NextFactory4 next_factory;
1726
+ };
1727
+ struct Running5 {
1728
+ union {
1729
+ GPR_NO_UNIQUE_ADDRESS Running4 prior;
1730
+ GPR_NO_UNIQUE_ADDRESS Promise5 current_promise;
1731
+ };
1732
+ GPR_NO_UNIQUE_ADDRESS NextFactory5 next_factory;
1733
+ };
1734
+ struct Running6 {
1735
+ union {
1736
+ GPR_NO_UNIQUE_ADDRESS Running5 prior;
1737
+ GPR_NO_UNIQUE_ADDRESS Promise6 current_promise;
1738
+ };
1739
+ GPR_NO_UNIQUE_ADDRESS NextFactory6 next_factory;
1740
+ };
1741
+ struct Running7 {
1742
+ union {
1743
+ GPR_NO_UNIQUE_ADDRESS Running6 prior;
1744
+ GPR_NO_UNIQUE_ADDRESS Promise7 current_promise;
1745
+ };
1746
+ GPR_NO_UNIQUE_ADDRESS NextFactory7 next_factory;
1747
+ };
1748
+ union {
1749
+ GPR_NO_UNIQUE_ADDRESS Running7 prior;
1750
+ GPR_NO_UNIQUE_ADDRESS Promise8 current_promise;
1751
+ };
1752
+ enum class State : uint8_t {
1753
+ kState0,
1754
+ kState1,
1755
+ kState2,
1756
+ kState3,
1757
+ kState4,
1758
+ kState5,
1759
+ kState6,
1760
+ kState7,
1761
+ kState8
1762
+ };
1763
+ GPR_NO_UNIQUE_ADDRESS State state = State::kState0;
1764
+
1765
+ SeqState(P&& p, F0&& f0, F1&& f1, F2&& f2, F3&& f3, F4&& f4, F5&& f5, F6&& f6,
1766
+ F7&& f7) noexcept {
1767
+ Construct(&prior.prior.prior.prior.prior.prior.prior.prior.current_promise,
1768
+ std::forward<P>(p));
1769
+ Construct(&prior.prior.prior.prior.prior.prior.prior.prior.next_factory,
1770
+ std::forward<F0>(f0));
1771
+ Construct(&prior.prior.prior.prior.prior.prior.prior.next_factory,
1772
+ std::forward<F1>(f1));
1773
+ Construct(&prior.prior.prior.prior.prior.prior.next_factory,
1774
+ std::forward<F2>(f2));
1775
+ Construct(&prior.prior.prior.prior.prior.next_factory,
1776
+ std::forward<F3>(f3));
1777
+ Construct(&prior.prior.prior.prior.next_factory, std::forward<F4>(f4));
1778
+ Construct(&prior.prior.prior.next_factory, std::forward<F5>(f5));
1779
+ Construct(&prior.prior.next_factory, std::forward<F6>(f6));
1780
+ Construct(&prior.next_factory, std::forward<F7>(f7));
1781
+ }
1782
+ ~SeqState() {
1783
+ switch (state) {
1784
+ case State::kState0:
1785
+ Destruct(
1786
+ &prior.prior.prior.prior.prior.prior.prior.prior.current_promise);
1787
+ goto tail0;
1788
+ case State::kState1:
1789
+ Destruct(&prior.prior.prior.prior.prior.prior.prior.current_promise);
1790
+ goto tail1;
1791
+ case State::kState2:
1792
+ Destruct(&prior.prior.prior.prior.prior.prior.current_promise);
1793
+ goto tail2;
1794
+ case State::kState3:
1795
+ Destruct(&prior.prior.prior.prior.prior.current_promise);
1796
+ goto tail3;
1797
+ case State::kState4:
1798
+ Destruct(&prior.prior.prior.prior.current_promise);
1799
+ goto tail4;
1800
+ case State::kState5:
1801
+ Destruct(&prior.prior.prior.current_promise);
1802
+ goto tail5;
1803
+ case State::kState6:
1804
+ Destruct(&prior.prior.current_promise);
1805
+ goto tail6;
1806
+ case State::kState7:
1807
+ Destruct(&prior.current_promise);
1808
+ goto tail7;
1809
+ case State::kState8:
1810
+ Destruct(&current_promise);
1811
+ return;
1812
+ }
1813
+ tail0:
1814
+ Destruct(&prior.prior.prior.prior.prior.prior.prior.prior.next_factory);
1815
+ tail1:
1816
+ Destruct(&prior.prior.prior.prior.prior.prior.prior.next_factory);
1817
+ tail2:
1818
+ Destruct(&prior.prior.prior.prior.prior.prior.next_factory);
1819
+ tail3:
1820
+ Destruct(&prior.prior.prior.prior.prior.next_factory);
1821
+ tail4:
1822
+ Destruct(&prior.prior.prior.prior.next_factory);
1823
+ tail5:
1824
+ Destruct(&prior.prior.prior.next_factory);
1825
+ tail6:
1826
+ Destruct(&prior.prior.next_factory);
1827
+ tail7:
1828
+ Destruct(&prior.next_factory);
1829
+ }
1830
+ SeqState(const SeqState& other) noexcept : state(other.state) {
1831
+ GPR_ASSERT(state == State::kState0);
1832
+ Construct(&prior.current_promise, other.prior.current_promise);
1833
+ Construct(
1834
+ &prior.prior.prior.prior.prior.prior.prior.prior.next_factory,
1835
+ other.prior.prior.prior.prior.prior.prior.prior.prior.next_factory);
1836
+ Construct(&prior.prior.prior.prior.prior.prior.prior.next_factory,
1837
+ other.prior.prior.prior.prior.prior.prior.prior.next_factory);
1838
+ Construct(&prior.prior.prior.prior.prior.prior.next_factory,
1839
+ other.prior.prior.prior.prior.prior.prior.next_factory);
1840
+ Construct(&prior.prior.prior.prior.prior.next_factory,
1841
+ other.prior.prior.prior.prior.prior.next_factory);
1842
+ Construct(&prior.prior.prior.prior.next_factory,
1843
+ other.prior.prior.prior.prior.next_factory);
1844
+ Construct(&prior.prior.prior.next_factory,
1845
+ other.prior.prior.prior.next_factory);
1846
+ Construct(&prior.prior.next_factory, other.prior.prior.next_factory);
1847
+ Construct(&prior.next_factory, other.prior.next_factory);
1848
+ }
1849
+ SeqState& operator=(const SeqState& other) = delete;
1850
+ SeqState(SeqState&& other) noexcept : state(other.state) {
1851
+ switch (state) {
1852
+ case State::kState0:
1853
+ Construct(
1854
+ &prior.prior.prior.prior.prior.prior.prior.prior.current_promise,
1855
+ std::move(other.prior.prior.prior.prior.prior.prior.prior.prior
1856
+ .current_promise));
1857
+ goto tail0;
1858
+ case State::kState1:
1859
+ Construct(&prior.prior.prior.prior.prior.prior.prior.current_promise,
1860
+ std::move(other.prior.prior.prior.prior.prior.prior.prior
1861
+ .current_promise));
1862
+ goto tail1;
1863
+ case State::kState2:
1864
+ Construct(
1865
+ &prior.prior.prior.prior.prior.prior.current_promise,
1866
+ std::move(
1867
+ other.prior.prior.prior.prior.prior.prior.current_promise));
1868
+ goto tail2;
1869
+ case State::kState3:
1870
+ Construct(
1871
+ &prior.prior.prior.prior.prior.current_promise,
1872
+ std::move(other.prior.prior.prior.prior.prior.current_promise));
1873
+ goto tail3;
1874
+ case State::kState4:
1875
+ Construct(&prior.prior.prior.prior.current_promise,
1876
+ std::move(other.prior.prior.prior.prior.current_promise));
1877
+ goto tail4;
1878
+ case State::kState5:
1879
+ Construct(&prior.prior.prior.current_promise,
1880
+ std::move(other.prior.prior.prior.current_promise));
1881
+ goto tail5;
1882
+ case State::kState6:
1883
+ Construct(&prior.prior.current_promise,
1884
+ std::move(other.prior.prior.current_promise));
1885
+ goto tail6;
1886
+ case State::kState7:
1887
+ Construct(&prior.current_promise,
1888
+ std::move(other.prior.current_promise));
1889
+ goto tail7;
1890
+ case State::kState8:
1891
+ Construct(&current_promise, std::move(other.current_promise));
1892
+ return;
1893
+ }
1894
+ tail0:
1895
+ Construct(&prior.prior.prior.prior.prior.prior.prior.prior.next_factory,
1896
+ std::move(other.prior.prior.prior.prior.prior.prior.prior.prior
1897
+ .next_factory));
1898
+ tail1:
1899
+ Construct(
1900
+ &prior.prior.prior.prior.prior.prior.prior.next_factory,
1901
+ std::move(
1902
+ other.prior.prior.prior.prior.prior.prior.prior.next_factory));
1903
+ tail2:
1904
+ Construct(
1905
+ &prior.prior.prior.prior.prior.prior.next_factory,
1906
+ std::move(other.prior.prior.prior.prior.prior.prior.next_factory));
1907
+ tail3:
1908
+ Construct(&prior.prior.prior.prior.prior.next_factory,
1909
+ std::move(other.prior.prior.prior.prior.prior.next_factory));
1910
+ tail4:
1911
+ Construct(&prior.prior.prior.prior.next_factory,
1912
+ std::move(other.prior.prior.prior.prior.next_factory));
1913
+ tail5:
1914
+ Construct(&prior.prior.prior.next_factory,
1915
+ std::move(other.prior.prior.prior.next_factory));
1916
+ tail6:
1917
+ Construct(&prior.prior.next_factory,
1918
+ std::move(other.prior.prior.next_factory));
1919
+ tail7:
1920
+ Construct(&prior.next_factory, std::move(other.prior.next_factory));
1921
+ }
1922
+ SeqState& operator=(SeqState&& other) = delete;
1923
+ Poll<Result> PollOnce() {
1924
+ switch (state) {
1925
+ case State::kState0: {
1926
+ auto result =
1927
+ prior.prior.prior.prior.prior.prior.prior.prior.current_promise();
1928
+ PromiseResult0* p = result.value_if_ready();
1929
+ if (p == nullptr) return Pending{};
1930
+ if (!PromiseResultTraits0::IsOk(*p)) {
1931
+ return PromiseResultTraits0::template ReturnValue<Result>(
1932
+ std::move(*p));
1933
+ }
1934
+ Destruct(
1935
+ &prior.prior.prior.prior.prior.prior.prior.prior.current_promise);
1936
+ auto next_promise = PromiseResultTraits0::CallFactory(
1937
+ &prior.prior.prior.prior.prior.prior.prior.prior.next_factory,
1938
+ std::move(*p));
1939
+ Destruct(&prior.prior.prior.prior.prior.prior.prior.prior.next_factory);
1940
+ Construct(&prior.prior.prior.prior.prior.prior.prior.current_promise,
1941
+ std::move(next_promise));
1942
+ state = State::kState1;
1943
+ }
1944
+ ABSL_FALLTHROUGH_INTENDED;
1945
+ case State::kState1: {
1946
+ auto result =
1947
+ prior.prior.prior.prior.prior.prior.prior.current_promise();
1948
+ PromiseResult1* p = result.value_if_ready();
1949
+ if (p == nullptr) return Pending{};
1950
+ if (!PromiseResultTraits1::IsOk(*p)) {
1951
+ return PromiseResultTraits1::template ReturnValue<Result>(
1952
+ std::move(*p));
1953
+ }
1954
+ Destruct(&prior.prior.prior.prior.prior.prior.prior.current_promise);
1955
+ auto next_promise = PromiseResultTraits1::CallFactory(
1956
+ &prior.prior.prior.prior.prior.prior.prior.next_factory,
1957
+ std::move(*p));
1958
+ Destruct(&prior.prior.prior.prior.prior.prior.prior.next_factory);
1959
+ Construct(&prior.prior.prior.prior.prior.prior.current_promise,
1960
+ std::move(next_promise));
1961
+ state = State::kState2;
1962
+ }
1963
+ ABSL_FALLTHROUGH_INTENDED;
1964
+ case State::kState2: {
1965
+ auto result = prior.prior.prior.prior.prior.prior.current_promise();
1966
+ PromiseResult2* p = result.value_if_ready();
1967
+ if (p == nullptr) return Pending{};
1968
+ if (!PromiseResultTraits2::IsOk(*p)) {
1969
+ return PromiseResultTraits2::template ReturnValue<Result>(
1970
+ std::move(*p));
1971
+ }
1972
+ Destruct(&prior.prior.prior.prior.prior.prior.current_promise);
1973
+ auto next_promise = PromiseResultTraits2::CallFactory(
1974
+ &prior.prior.prior.prior.prior.prior.next_factory, std::move(*p));
1975
+ Destruct(&prior.prior.prior.prior.prior.prior.next_factory);
1976
+ Construct(&prior.prior.prior.prior.prior.current_promise,
1977
+ std::move(next_promise));
1978
+ state = State::kState3;
1979
+ }
1980
+ ABSL_FALLTHROUGH_INTENDED;
1981
+ case State::kState3: {
1982
+ auto result = prior.prior.prior.prior.prior.current_promise();
1983
+ PromiseResult3* p = result.value_if_ready();
1984
+ if (p == nullptr) return Pending{};
1985
+ if (!PromiseResultTraits3::IsOk(*p)) {
1986
+ return PromiseResultTraits3::template ReturnValue<Result>(
1987
+ std::move(*p));
1988
+ }
1989
+ Destruct(&prior.prior.prior.prior.prior.current_promise);
1990
+ auto next_promise = PromiseResultTraits3::CallFactory(
1991
+ &prior.prior.prior.prior.prior.next_factory, std::move(*p));
1992
+ Destruct(&prior.prior.prior.prior.prior.next_factory);
1993
+ Construct(&prior.prior.prior.prior.current_promise,
1994
+ std::move(next_promise));
1995
+ state = State::kState4;
1996
+ }
1997
+ ABSL_FALLTHROUGH_INTENDED;
1998
+ case State::kState4: {
1999
+ auto result = prior.prior.prior.prior.current_promise();
2000
+ PromiseResult4* p = result.value_if_ready();
2001
+ if (p == nullptr) return Pending{};
2002
+ if (!PromiseResultTraits4::IsOk(*p)) {
2003
+ return PromiseResultTraits4::template ReturnValue<Result>(
2004
+ std::move(*p));
2005
+ }
2006
+ Destruct(&prior.prior.prior.prior.current_promise);
2007
+ auto next_promise = PromiseResultTraits4::CallFactory(
2008
+ &prior.prior.prior.prior.next_factory, std::move(*p));
2009
+ Destruct(&prior.prior.prior.prior.next_factory);
2010
+ Construct(&prior.prior.prior.current_promise, std::move(next_promise));
2011
+ state = State::kState5;
2012
+ }
2013
+ ABSL_FALLTHROUGH_INTENDED;
2014
+ case State::kState5: {
2015
+ auto result = prior.prior.prior.current_promise();
2016
+ PromiseResult5* p = result.value_if_ready();
2017
+ if (p == nullptr) return Pending{};
2018
+ if (!PromiseResultTraits5::IsOk(*p)) {
2019
+ return PromiseResultTraits5::template ReturnValue<Result>(
2020
+ std::move(*p));
2021
+ }
2022
+ Destruct(&prior.prior.prior.current_promise);
2023
+ auto next_promise = PromiseResultTraits5::CallFactory(
2024
+ &prior.prior.prior.next_factory, std::move(*p));
2025
+ Destruct(&prior.prior.prior.next_factory);
2026
+ Construct(&prior.prior.current_promise, std::move(next_promise));
2027
+ state = State::kState6;
2028
+ }
2029
+ ABSL_FALLTHROUGH_INTENDED;
2030
+ case State::kState6: {
2031
+ auto result = prior.prior.current_promise();
2032
+ PromiseResult6* p = result.value_if_ready();
2033
+ if (p == nullptr) return Pending{};
2034
+ if (!PromiseResultTraits6::IsOk(*p)) {
2035
+ return PromiseResultTraits6::template ReturnValue<Result>(
2036
+ std::move(*p));
2037
+ }
2038
+ Destruct(&prior.prior.current_promise);
2039
+ auto next_promise = PromiseResultTraits6::CallFactory(
2040
+ &prior.prior.next_factory, std::move(*p));
2041
+ Destruct(&prior.prior.next_factory);
2042
+ Construct(&prior.current_promise, std::move(next_promise));
2043
+ state = State::kState7;
2044
+ }
2045
+ ABSL_FALLTHROUGH_INTENDED;
2046
+ case State::kState7: {
2047
+ auto result = prior.current_promise();
2048
+ PromiseResult7* p = result.value_if_ready();
2049
+ if (p == nullptr) return Pending{};
2050
+ if (!PromiseResultTraits7::IsOk(*p)) {
2051
+ return PromiseResultTraits7::template ReturnValue<Result>(
2052
+ std::move(*p));
2053
+ }
2054
+ Destruct(&prior.current_promise);
2055
+ auto next_promise = PromiseResultTraits7::CallFactory(
2056
+ &prior.next_factory, std::move(*p));
2057
+ Destruct(&prior.next_factory);
2058
+ Construct(&current_promise, std::move(next_promise));
2059
+ state = State::kState8;
2060
+ }
2061
+ ABSL_FALLTHROUGH_INTENDED;
2062
+ default:
2063
+ case State::kState8: {
2064
+ auto result = current_promise();
2065
+ auto* p = result.value_if_ready();
2066
+ if (p == nullptr) return Pending{};
2067
+ return Result(std::move(*p));
2068
+ }
2069
+ }
2070
+ }
2071
+ };
2072
+
2073
+ } // namespace promise_detail
2074
+ } // namespace grpc_core
2075
+
2076
+ #endif // GRPC_SRC_CORE_LIB_PROMISE_DETAIL_SEQ_STATE_H