From 518943adf13bea78bfa91011b9b3b27eb8b9b9f4 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 14 Feb 2025 11:42:31 -0800 Subject: [PATCH] [promises] Bring back non-copyable seqs/joins (#38744) I made seqs/joins copyable a while ago in anticipation of a nice optimization -- that didn't pan out. Having them copyable makes it more likely that `Loop` will accept them and try to turn them from promises into the promise factory that it expects, copying the insides... *which is usually wrong* and incredibly frustrating to debug. Closes #38744 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/38744 from ctiller:promising e7a0e8d0bbf084a764378a855c3e0ef8e5b66c6b PiperOrigin-RevId: 727006243 --- src/core/lib/promise/detail/join_state.h | 84 ++---- src/core/lib/promise/detail/seq_state.h | 280 +++----------------- src/core/lib/promise/loop.h | 4 +- tools/codegen/core/gen_join.py | 7 +- tools/codegen/core/templates/seq_state.mako | 10 +- 5 files changed, 63 insertions(+), 322 deletions(-) diff --git a/src/core/lib/promise/detail/join_state.h b/src/core/lib/promise/detail/join_state.h index 767ca8d787dfe..c9dc27bc3e1df 100644 --- a/src/core/lib/promise/detail/join_state.h +++ b/src/core/lib/promise/detail/join_state.h @@ -57,11 +57,8 @@ struct JoinState { Construct(&promise0, std::forward(p0)); Construct(&promise1, std::forward(p1)); } - GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(const JoinState& other) { - DCHECK(other.ready.none()); - Construct(&promise0, other.promise0); - Construct(&promise1, other.promise1); - } + GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(const JoinState& other) = + delete; JoinState& operator=(const JoinState& other) = delete; JoinState& operator=(JoinState&& other) = delete; GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept { @@ -163,12 +160,8 @@ struct JoinState { Construct(&promise1, std::forward(p1)); Construct(&promise2, std::forward(p2)); } - GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(const JoinState& other) { - DCHECK(other.ready.none()); - Construct(&promise0, other.promise0); - Construct(&promise1, other.promise1); - Construct(&promise2, other.promise2); - } + GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(const JoinState& other) = + delete; JoinState& operator=(const JoinState& other) = delete; JoinState& operator=(JoinState&& other) = delete; GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept { @@ -307,13 +300,8 @@ struct JoinState { Construct(&promise2, std::forward(p2)); Construct(&promise3, std::forward(p3)); } - GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(const JoinState& other) { - DCHECK(other.ready.none()); - Construct(&promise0, other.promise0); - Construct(&promise1, other.promise1); - Construct(&promise2, other.promise2); - Construct(&promise3, other.promise3); - } + GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(const JoinState& other) = + delete; JoinState& operator=(const JoinState& other) = delete; JoinState& operator=(JoinState&& other) = delete; GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept { @@ -488,14 +476,8 @@ struct JoinState { Construct(&promise3, std::forward(p3)); Construct(&promise4, std::forward(p4)); } - GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(const JoinState& other) { - DCHECK(other.ready.none()); - Construct(&promise0, other.promise0); - Construct(&promise1, other.promise1); - Construct(&promise2, other.promise2); - Construct(&promise3, other.promise3); - Construct(&promise4, other.promise4); - } + GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(const JoinState& other) = + delete; JoinState& operator=(const JoinState& other) = delete; JoinState& operator=(JoinState&& other) = delete; GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept { @@ -706,15 +688,8 @@ struct JoinState { Construct(&promise4, std::forward(p4)); Construct(&promise5, std::forward(p5)); } - GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(const JoinState& other) { - DCHECK(other.ready.none()); - Construct(&promise0, other.promise0); - Construct(&promise1, other.promise1); - Construct(&promise2, other.promise2); - Construct(&promise3, other.promise3); - Construct(&promise4, other.promise4); - Construct(&promise5, other.promise5); - } + GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(const JoinState& other) = + delete; JoinState& operator=(const JoinState& other) = delete; JoinState& operator=(JoinState&& other) = delete; GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept { @@ -961,16 +936,8 @@ struct JoinState { Construct(&promise5, std::forward(p5)); Construct(&promise6, std::forward(p6)); } - GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(const JoinState& other) { - DCHECK(other.ready.none()); - Construct(&promise0, other.promise0); - Construct(&promise1, other.promise1); - Construct(&promise2, other.promise2); - Construct(&promise3, other.promise3); - Construct(&promise4, other.promise4); - Construct(&promise5, other.promise5); - Construct(&promise6, other.promise6); - } + GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(const JoinState& other) = + delete; JoinState& operator=(const JoinState& other) = delete; JoinState& operator=(JoinState&& other) = delete; GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept { @@ -1253,17 +1220,8 @@ struct JoinState { Construct(&promise6, std::forward(p6)); Construct(&promise7, std::forward(p7)); } - GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(const JoinState& other) { - DCHECK(other.ready.none()); - Construct(&promise0, other.promise0); - Construct(&promise1, other.promise1); - Construct(&promise2, other.promise2); - Construct(&promise3, other.promise3); - Construct(&promise4, other.promise4); - Construct(&promise5, other.promise5); - Construct(&promise6, other.promise6); - Construct(&promise7, other.promise7); - } + GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(const JoinState& other) = + delete; JoinState& operator=(const JoinState& other) = delete; JoinState& operator=(JoinState&& other) = delete; GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept { @@ -1581,18 +1539,8 @@ struct JoinState { Construct(&promise7, std::forward(p7)); Construct(&promise8, std::forward(p8)); } - GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(const JoinState& other) { - DCHECK(other.ready.none()); - Construct(&promise0, other.promise0); - Construct(&promise1, other.promise1); - Construct(&promise2, other.promise2); - Construct(&promise3, other.promise3); - Construct(&promise4, other.promise4); - Construct(&promise5, other.promise5); - Construct(&promise6, other.promise6); - Construct(&promise7, other.promise7); - Construct(&promise8, other.promise8); - } + GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(const JoinState& other) = + delete; JoinState& operator=(const JoinState& other) = delete; JoinState& operator=(JoinState&& other) = delete; GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept { diff --git a/src/core/lib/promise/detail/seq_state.h b/src/core/lib/promise/detail/seq_state.h index a83f346983ae3..184cf5f4954c9 100644 --- a/src/core/lib/promise/detail/seq_state.h +++ b/src/core/lib/promise/detail/seq_state.h @@ -73,6 +73,37 @@ // here. The very first state does not have a prior state, and so that state has // a partial specialization below. The final state does not have a next state; // that state is inlined in BasicSeq since that was simpler to type. +// +// The final state machine is built only after a simplification pass over the +// sequence. This pass examines the sequence and leverages subsequences that +// are known to be instantaneous to avoid the overhead of the state machine. +// How do we know something is instantaneous? If the promise factory returns +// something other than a promise that returns Poll<> then we know we can +// evaluate it immediately. +// +// Simplification proceeds in four phases: +// +// Phase 1: Labelling, inside Simplify() +// Here we construct a bitfield that tells us which steps are instantaneous +// and which ones are not. This allows us to leverage constexpr if over the +// bitfield to speed up compilation and simplify the logic herein. +// The bitfield is constructed such that the 0 bit corresponds to the last +// factory in the sequence, and the n-1 bit corresponds to the first factory. +// This is a bit confusing when doing the shifts and masks, but ensures that +// the bit pattern that shows up in the generated text is in the same order +// as the promise factories in the argument lists to Simplify() and friends, +// which greatly aids in debugging. +// Phase 2: Right Simplification, inside SimplifyRight(): +// Here we take advantage of the identity Seq(A, I) == Map(A, I) for a +// promise A and an instantanious promise factory I. We examine the last +// bits of the bitfield and merge together all trailing instantaneous steps +// into a single map. +// Phase 3: Left Simplification, inside SimplifyLeft(): +// Leveraging the same identity, we now look to the first bits of the +// bitfield, and merge any instantaneous steps into the first promise. +// Phase 4: Middle Simplification, inside SimplifyMiddle(): +// Here we look at the remaining steps in the bitfield and merge sequences +// of instantaneous steps into a single map. namespace grpc_core { namespace promise_detail { @@ -719,12 +750,7 @@ struct SeqState { tail0: Destruct(&prior.next_factory); } - GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) noexcept - : state(other.state), whence(other.whence) { - DCHECK(state == State::kState0); - Construct(&prior.current_promise, other.prior.current_promise); - Construct(&prior.next_factory, other.prior.next_factory); - } + GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) = delete; SeqState& operator=(const SeqState& other) = delete; GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(SeqState&& other) noexcept : state(other.state), whence(other.whence) { @@ -841,13 +867,7 @@ struct SeqState { tail1: Destruct(&prior.next_factory); } - GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) noexcept - : state(other.state), whence(other.whence) { - DCHECK(state == State::kState0); - Construct(&prior.prior.current_promise, other.prior.prior.current_promise); - Construct(&prior.prior.next_factory, other.prior.prior.next_factory); - Construct(&prior.next_factory, other.prior.next_factory); - } + GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) = delete; SeqState& operator=(const SeqState& other) = delete; GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(SeqState&& other) noexcept : state(other.state), whence(other.whence) { @@ -1014,16 +1034,7 @@ struct SeqState { tail2: Destruct(&prior.next_factory); } - GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) noexcept - : state(other.state), whence(other.whence) { - DCHECK(state == State::kState0); - Construct(&prior.prior.prior.current_promise, - other.prior.prior.prior.current_promise); - Construct(&prior.prior.prior.next_factory, - other.prior.prior.prior.next_factory); - Construct(&prior.prior.next_factory, other.prior.prior.next_factory); - Construct(&prior.next_factory, other.prior.next_factory); - } + GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) = delete; SeqState& operator=(const SeqState& other) = delete; GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(SeqState&& other) noexcept : state(other.state), whence(other.whence) { @@ -1238,18 +1249,7 @@ struct SeqState { tail3: Destruct(&prior.next_factory); } - GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) noexcept - : state(other.state), whence(other.whence) { - DCHECK(state == State::kState0); - Construct(&prior.prior.prior.prior.current_promise, - other.prior.prior.prior.prior.current_promise); - Construct(&prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.next_factory, - other.prior.prior.prior.next_factory); - Construct(&prior.prior.next_factory, other.prior.prior.next_factory); - Construct(&prior.next_factory, other.prior.next_factory); - } + GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) = delete; SeqState& operator=(const SeqState& other) = delete; GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(SeqState&& other) noexcept : state(other.state), whence(other.whence) { @@ -1521,20 +1521,7 @@ struct SeqState { tail4: Destruct(&prior.next_factory); } - GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) noexcept - : state(other.state), whence(other.whence) { - DCHECK(state == State::kState0); - Construct(&prior.prior.prior.prior.prior.current_promise, - other.prior.prior.prior.prior.prior.current_promise); - Construct(&prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.next_factory, - other.prior.prior.prior.next_factory); - Construct(&prior.prior.next_factory, other.prior.prior.next_factory); - Construct(&prior.next_factory, other.prior.next_factory); - } + GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) = delete; SeqState& operator=(const SeqState& other) = delete; GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(SeqState&& other) noexcept : state(other.state), whence(other.whence) { @@ -1858,22 +1845,7 @@ struct SeqState { tail5: Destruct(&prior.next_factory); } - GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) noexcept - : state(other.state), whence(other.whence) { - DCHECK(state == State::kState0); - Construct(&prior.prior.prior.prior.prior.prior.current_promise, - other.prior.prior.prior.prior.prior.prior.current_promise); - Construct(&prior.prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.next_factory, - other.prior.prior.prior.next_factory); - Construct(&prior.prior.next_factory, other.prior.prior.next_factory); - Construct(&prior.next_factory, other.prior.next_factory); - } + GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) = delete; SeqState& operator=(const SeqState& other) = delete; GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(SeqState&& other) noexcept : state(other.state), whence(other.whence) { @@ -2251,24 +2223,7 @@ struct SeqState { tail6: Destruct(&prior.next_factory); } - GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) noexcept - : state(other.state), whence(other.whence) { - DCHECK(state == State::kState0); - Construct(&prior.prior.prior.prior.prior.prior.prior.current_promise, - other.prior.prior.prior.prior.prior.prior.prior.current_promise); - Construct(&prior.prior.prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.next_factory, - other.prior.prior.prior.next_factory); - Construct(&prior.prior.next_factory, other.prior.prior.next_factory); - Construct(&prior.next_factory, other.prior.next_factory); - } + GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) = delete; SeqState& operator=(const SeqState& other) = delete; GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(SeqState&& other) noexcept : state(other.state), whence(other.whence) { @@ -2703,28 +2658,7 @@ struct SeqState { tail7: Destruct(&prior.next_factory); } - GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) noexcept - : state(other.state), whence(other.whence) { - DCHECK(state == State::kState0); - Construct( - &prior.prior.prior.prior.prior.prior.prior.prior.current_promise, - other.prior.prior.prior.prior.prior.prior.prior.prior.current_promise); - Construct( - &prior.prior.prior.prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.next_factory, - other.prior.prior.prior.next_factory); - Construct(&prior.prior.next_factory, other.prior.prior.next_factory); - Construct(&prior.next_factory, other.prior.next_factory); - } + GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) = delete; SeqState& operator=(const SeqState& other) = delete; GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(SeqState&& other) noexcept : state(other.state), whence(other.whence) { @@ -3218,33 +3152,7 @@ struct SeqState { tail8: Destruct(&prior.next_factory); } - GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) noexcept - : state(other.state), whence(other.whence) { - DCHECK(state == State::kState0); - Construct( - &prior.prior.prior.prior.prior.prior.prior.prior.prior.current_promise, - other.prior.prior.prior.prior.prior.prior.prior.prior.prior - .current_promise); - Construct( - &prior.prior.prior.prior.prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.prior.prior.prior.prior - .next_factory); - Construct( - &prior.prior.prior.prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.next_factory, - other.prior.prior.prior.next_factory); - Construct(&prior.prior.next_factory, other.prior.prior.next_factory); - Construct(&prior.next_factory, other.prior.next_factory); - } + GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) = delete; SeqState& operator=(const SeqState& other) = delete; GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(SeqState&& other) noexcept : state(other.state), whence(other.whence) { @@ -3801,37 +3709,7 @@ struct SeqState { tail9: Destruct(&prior.next_factory); } - GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) noexcept - : state(other.state), whence(other.whence) { - DCHECK(state == State::kState0); - Construct(&prior.prior.prior.prior.prior.prior.prior.prior.prior.prior - .current_promise, - other.prior.prior.prior.prior.prior.prior.prior.prior.prior.prior - .current_promise); - Construct(&prior.prior.prior.prior.prior.prior.prior.prior.prior.prior - .next_factory, - other.prior.prior.prior.prior.prior.prior.prior.prior.prior.prior - .next_factory); - Construct( - &prior.prior.prior.prior.prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.prior.prior.prior.prior - .next_factory); - Construct( - &prior.prior.prior.prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.next_factory, - other.prior.prior.prior.next_factory); - Construct(&prior.prior.next_factory, other.prior.prior.next_factory); - Construct(&prior.next_factory, other.prior.next_factory); - } + GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) = delete; SeqState& operator=(const SeqState& other) = delete; GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(SeqState&& other) noexcept : state(other.state), whence(other.whence) { @@ -4450,41 +4328,7 @@ struct SeqState { tail10: Destruct(&prior.next_factory); } - GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) noexcept - : state(other.state), whence(other.whence) { - DCHECK(state == State::kState0); - Construct(&prior.prior.prior.prior.prior.prior.prior.prior.prior.prior.prior - .current_promise, - other.prior.prior.prior.prior.prior.prior.prior.prior.prior.prior - .prior.current_promise); - Construct(&prior.prior.prior.prior.prior.prior.prior.prior.prior.prior.prior - .next_factory, - other.prior.prior.prior.prior.prior.prior.prior.prior.prior.prior - .prior.next_factory); - Construct(&prior.prior.prior.prior.prior.prior.prior.prior.prior.prior - .next_factory, - other.prior.prior.prior.prior.prior.prior.prior.prior.prior.prior - .next_factory); - Construct( - &prior.prior.prior.prior.prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.prior.prior.prior.prior - .next_factory); - Construct( - &prior.prior.prior.prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.next_factory, - other.prior.prior.prior.next_factory); - Construct(&prior.prior.next_factory, other.prior.prior.next_factory); - Construct(&prior.next_factory, other.prior.next_factory); - } + GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) = delete; SeqState& operator=(const SeqState& other) = delete; GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(SeqState&& other) noexcept : state(other.state), whence(other.whence) { @@ -5168,45 +5012,7 @@ struct SeqState { tail11: Destruct(&prior.next_factory); } - GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) noexcept - : state(other.state), whence(other.whence) { - DCHECK(state == State::kState0); - Construct(&prior.prior.prior.prior.prior.prior.prior.prior.prior.prior.prior - .prior.current_promise, - other.prior.prior.prior.prior.prior.prior.prior.prior.prior.prior - .prior.prior.current_promise); - Construct(&prior.prior.prior.prior.prior.prior.prior.prior.prior.prior.prior - .prior.next_factory, - other.prior.prior.prior.prior.prior.prior.prior.prior.prior.prior - .prior.prior.next_factory); - Construct(&prior.prior.prior.prior.prior.prior.prior.prior.prior.prior.prior - .next_factory, - other.prior.prior.prior.prior.prior.prior.prior.prior.prior.prior - .prior.next_factory); - Construct(&prior.prior.prior.prior.prior.prior.prior.prior.prior.prior - .next_factory, - other.prior.prior.prior.prior.prior.prior.prior.prior.prior.prior - .next_factory); - Construct( - &prior.prior.prior.prior.prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.prior.prior.prior.prior - .next_factory); - Construct( - &prior.prior.prior.prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.prior.next_factory, - other.prior.prior.prior.prior.next_factory); - Construct(&prior.prior.prior.next_factory, - other.prior.prior.prior.next_factory); - Construct(&prior.prior.next_factory, other.prior.prior.next_factory); - Construct(&prior.next_factory, other.prior.next_factory); - } + GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) = delete; SeqState& operator=(const SeqState& other) = delete; GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(SeqState&& other) noexcept : state(other.state), whence(other.whence) { diff --git a/src/core/lib/promise/loop.h b/src/core/lib/promise/loop.h index 7cb6e0f0a8ab8..27df03bcfcae7 100644 --- a/src/core/lib/promise/loop.h +++ b/src/core/lib/promise/loop.h @@ -33,8 +33,8 @@ namespace grpc_core { // // Input: // -// 1. A Loop combinator takes as input only one promise or promise factory. -// 2. This input promise or promise factory should have a return type of either +// 1. A Loop combinator takes as input only one promise factory. +// 2. This input promise factory should have a return type of either // a. LoopCtl which is an alias for std::variant // b. Or Poll> // diff --git a/tools/codegen/core/gen_join.py b/tools/codegen/core/gen_join.py index 4f53a982d4174..3ab47ccd28f0b 100755 --- a/tools/codegen/core/gen_join.py +++ b/tools/codegen/core/gen_join.py @@ -38,12 +38,7 @@ Construct(&promise${i}, std::forward(p${i})); % endfor } - GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(const JoinState& other) { - DCHECK(other.ready.none()); -% for i in range(0,n): - Construct(&promise${i}, other.promise${i}); -% endfor - } + GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(const JoinState& other) = delete; JoinState& operator=(const JoinState& other) = delete; JoinState& operator=(JoinState&& other) = delete; GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept { diff --git a/tools/codegen/core/templates/seq_state.mako b/tools/codegen/core/templates/seq_state.mako index e3b3b0711c830..02e7cb9b32099 100644 --- a/tools/codegen/core/templates/seq_state.mako +++ b/tools/codegen/core/templates/seq_state.mako @@ -237,15 +237,7 @@ tail${i}: Destruct(&${"prior."*(n-1-i)}next_factory); % endfor } - GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) noexcept : state(other.state), whence(other.whence) { - DCHECK(state == State::kState0); - Construct(&${"prior."*(n-1)}current_promise, - other.${"prior."*(n-1)}current_promise); -% for i in range(0,n-1): - Construct(&${"prior."*(n-1-i)}next_factory, - other.${"prior."*(n-1-i)}next_factory); -% endfor - } + GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) = delete; SeqState& operator=(const SeqState& other) = delete; GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(SeqState&& other) noexcept : state(other.state), whence(other.whence) { DCHECK(state == State::kState0);