Skip to content

Commit

Permalink
[promises] Bring back non-copyable seqs/joins (grpc#38744)
Browse files Browse the repository at this point in the history
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 grpc#38744

COPYBARA_INTEGRATE_REVIEW=grpc#38744 from ctiller:promising e7a0e8d
PiperOrigin-RevId: 727006243
  • Loading branch information
ctiller authored and copybara-github committed Feb 14, 2025
1 parent 4330302 commit 518943a
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 322 deletions.
84 changes: 16 additions & 68 deletions src/core/lib/promise/detail/join_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,8 @@ struct JoinState<Traits, P0, P1> {
Construct(&promise0, std::forward<P0>(p0));
Construct(&promise1, std::forward<P1>(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 {
Expand Down Expand Up @@ -163,12 +160,8 @@ struct JoinState<Traits, P0, P1, P2> {
Construct(&promise1, std::forward<P1>(p1));
Construct(&promise2, std::forward<P2>(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 {
Expand Down Expand Up @@ -307,13 +300,8 @@ struct JoinState<Traits, P0, P1, P2, P3> {
Construct(&promise2, std::forward<P2>(p2));
Construct(&promise3, std::forward<P3>(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 {
Expand Down Expand Up @@ -488,14 +476,8 @@ struct JoinState<Traits, P0, P1, P2, P3, P4> {
Construct(&promise3, std::forward<P3>(p3));
Construct(&promise4, std::forward<P4>(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 {
Expand Down Expand Up @@ -706,15 +688,8 @@ struct JoinState<Traits, P0, P1, P2, P3, P4, P5> {
Construct(&promise4, std::forward<P4>(p4));
Construct(&promise5, std::forward<P5>(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 {
Expand Down Expand Up @@ -961,16 +936,8 @@ struct JoinState<Traits, P0, P1, P2, P3, P4, P5, P6> {
Construct(&promise5, std::forward<P5>(p5));
Construct(&promise6, std::forward<P6>(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 {
Expand Down Expand Up @@ -1253,17 +1220,8 @@ struct JoinState<Traits, P0, P1, P2, P3, P4, P5, P6, P7> {
Construct(&promise6, std::forward<P6>(p6));
Construct(&promise7, std::forward<P7>(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 {
Expand Down Expand Up @@ -1581,18 +1539,8 @@ struct JoinState<Traits, P0, P1, P2, P3, P4, P5, P6, P7, P8> {
Construct(&promise7, std::forward<P7>(p7));
Construct(&promise8, std::forward<P8>(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 {
Expand Down
Loading

0 comments on commit 518943a

Please sign in to comment.