pull/37145/head
Craig Tiller 5 months ago
parent da9e240833
commit 086620ecc9
  1. 40
      src/core/lib/promise/detail/join_state.h
  2. 86
      src/core/lib/promise/detail/seq_state.h
  3. 4
      tools/codegen/core/gen_join.py
  4. 8
      tools/codegen/core/gen_seq.py

@ -65,9 +65,8 @@ struct JoinState<Traits, P0, P1> {
}
JoinState& operator=(const JoinState& other) = delete;
JoinState& operator=(JoinState&& other) = delete;
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept
: ready(other.ready) {
DCHECK(ready.none());
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept {
DCHECK(other.ready.none());
Construct(&promise0, std::move(other.promise0));
Construct(&promise1, std::move(other.promise1));
}
@ -173,9 +172,8 @@ struct JoinState<Traits, P0, P1, P2> {
}
JoinState& operator=(const JoinState& other) = delete;
JoinState& operator=(JoinState&& other) = delete;
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept
: ready(other.ready) {
DCHECK(ready.none());
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept {
DCHECK(other.ready.none());
Construct(&promise0, std::move(other.promise0));
Construct(&promise1, std::move(other.promise1));
Construct(&promise2, std::move(other.promise2));
@ -319,9 +317,8 @@ struct JoinState<Traits, P0, P1, P2, P3> {
}
JoinState& operator=(const JoinState& other) = delete;
JoinState& operator=(JoinState&& other) = delete;
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept
: ready(other.ready) {
DCHECK(ready.none());
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept {
DCHECK(other.ready.none());
Construct(&promise0, std::move(other.promise0));
Construct(&promise1, std::move(other.promise1));
Construct(&promise2, std::move(other.promise2));
@ -502,9 +499,8 @@ struct JoinState<Traits, P0, P1, P2, P3, P4> {
}
JoinState& operator=(const JoinState& other) = delete;
JoinState& operator=(JoinState&& other) = delete;
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept
: ready(other.ready) {
DCHECK(ready.none());
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept {
DCHECK(other.ready.none());
Construct(&promise0, std::move(other.promise0));
Construct(&promise1, std::move(other.promise1));
Construct(&promise2, std::move(other.promise2));
@ -722,9 +718,8 @@ struct JoinState<Traits, P0, P1, P2, P3, P4, P5> {
}
JoinState& operator=(const JoinState& other) = delete;
JoinState& operator=(JoinState&& other) = delete;
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept
: ready(other.ready) {
DCHECK(ready.none());
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept {
DCHECK(other.ready.none());
Construct(&promise0, std::move(other.promise0));
Construct(&promise1, std::move(other.promise1));
Construct(&promise2, std::move(other.promise2));
@ -979,9 +974,8 @@ struct JoinState<Traits, P0, P1, P2, P3, P4, P5, P6> {
}
JoinState& operator=(const JoinState& other) = delete;
JoinState& operator=(JoinState&& other) = delete;
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept
: ready(other.ready) {
DCHECK(ready.none());
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept {
DCHECK(other.ready.none());
Construct(&promise0, std::move(other.promise0));
Construct(&promise1, std::move(other.promise1));
Construct(&promise2, std::move(other.promise2));
@ -1273,9 +1267,8 @@ struct JoinState<Traits, P0, P1, P2, P3, P4, P5, P6, P7> {
}
JoinState& operator=(const JoinState& other) = delete;
JoinState& operator=(JoinState&& other) = delete;
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept
: ready(other.ready) {
DCHECK(ready.none());
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept {
DCHECK(other.ready.none());
Construct(&promise0, std::move(other.promise0));
Construct(&promise1, std::move(other.promise1));
Construct(&promise2, std::move(other.promise2));
@ -1603,9 +1596,8 @@ struct JoinState<Traits, P0, P1, P2, P3, P4, P5, P6, P7, P8> {
}
JoinState& operator=(const JoinState& other) = delete;
JoinState& operator=(JoinState&& other) = delete;
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept
: ready(other.ready) {
DCHECK(ready.none());
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept {
DCHECK(other.ready.none());
Construct(&promise0, std::move(other.promise0));
Construct(&promise1, std::move(other.promise1));
Construct(&promise2, std::move(other.promise2));

@ -252,7 +252,7 @@ struct SeqState<Traits, P, F0, F1> {
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.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);
}
@ -260,7 +260,8 @@ struct SeqState<Traits, P, F0, F1> {
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(SeqState&& other) noexcept
: state(other.state), whence(other.whence) {
DCHECK(state == State::kState0);
Construct(&prior.current_promise, std::move(other.prior.current_promise));
Construct(&prior.prior.current_promise,
std::move(other.prior.prior.current_promise));
Construct(&prior.prior.next_factory,
std::move(other.prior.prior.next_factory));
Construct(&prior.next_factory, std::move(other.prior.next_factory));
@ -435,7 +436,8 @@ struct SeqState<Traits, P, F0, F1, F2> {
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.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);
@ -445,7 +447,8 @@ struct SeqState<Traits, P, F0, F1, F2> {
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(SeqState&& other) noexcept
: state(other.state), whence(other.whence) {
DCHECK(state == State::kState0);
Construct(&prior.current_promise, std::move(other.prior.current_promise));
Construct(&prior.prior.prior.current_promise,
std::move(other.prior.prior.prior.current_promise));
Construct(&prior.prior.prior.next_factory,
std::move(other.prior.prior.prior.next_factory));
Construct(&prior.prior.next_factory,
@ -672,7 +675,8 @@ struct SeqState<Traits, P, F0, F1, F2, F3> {
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.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,
@ -684,7 +688,8 @@ struct SeqState<Traits, P, F0, F1, F2, F3> {
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(SeqState&& other) noexcept
: state(other.state), whence(other.whence) {
DCHECK(state == State::kState0);
Construct(&prior.current_promise, std::move(other.prior.current_promise));
Construct(&prior.prior.prior.prior.current_promise,
std::move(other.prior.prior.prior.prior.current_promise));
Construct(&prior.prior.prior.prior.next_factory,
std::move(other.prior.prior.prior.prior.next_factory));
Construct(&prior.prior.prior.next_factory,
@ -972,7 +977,8 @@ struct SeqState<Traits, P, F0, F1, F2, F3, F4> {
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.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,
@ -986,7 +992,8 @@ struct SeqState<Traits, P, F0, F1, F2, F3, F4> {
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(SeqState&& other) noexcept
: state(other.state), whence(other.whence) {
DCHECK(state == State::kState0);
Construct(&prior.current_promise, std::move(other.prior.current_promise));
Construct(&prior.prior.prior.prior.prior.current_promise,
std::move(other.prior.prior.prior.prior.prior.current_promise));
Construct(&prior.prior.prior.prior.prior.next_factory,
std::move(other.prior.prior.prior.prior.prior.next_factory));
Construct(&prior.prior.prior.prior.next_factory,
@ -1330,7 +1337,8 @@ struct SeqState<Traits, P, F0, F1, F2, F3, F4, F5> {
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.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,
@ -1346,7 +1354,9 @@ struct SeqState<Traits, P, F0, F1, F2, F3, F4, F5> {
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(SeqState&& other) noexcept
: state(other.state), whence(other.whence) {
DCHECK(state == State::kState0);
Construct(&prior.current_promise, std::move(other.prior.current_promise));
Construct(
&prior.prior.prior.prior.prior.prior.current_promise,
std::move(other.prior.prior.prior.prior.prior.prior.current_promise));
Construct(
&prior.prior.prior.prior.prior.prior.next_factory,
std::move(other.prior.prior.prior.prior.prior.prior.next_factory));
@ -1747,7 +1757,8 @@ struct SeqState<Traits, P, F0, F1, F2, F3, F4, F5, F6> {
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.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,
@ -1765,7 +1776,10 @@ struct SeqState<Traits, P, F0, F1, F2, F3, F4, F5, F6> {
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(SeqState&& other) noexcept
: state(other.state), whence(other.whence) {
DCHECK(state == State::kState0);
Construct(&prior.current_promise, std::move(other.prior.current_promise));
Construct(
&prior.prior.prior.prior.prior.prior.prior.current_promise,
std::move(
other.prior.prior.prior.prior.prior.prior.prior.current_promise));
Construct(
&prior.prior.prior.prior.prior.prior.prior.next_factory,
std::move(
@ -2226,7 +2240,9 @@ struct SeqState<Traits, P, F0, F1, F2, F3, F4, F5, F6, F7> {
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.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);
@ -2247,7 +2263,9 @@ struct SeqState<Traits, P, F0, F1, F2, F3, F4, F5, F6, F7> {
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(SeqState&& other) noexcept
: state(other.state), whence(other.whence) {
DCHECK(state == State::kState0);
Construct(&prior.current_promise, std::move(other.prior.current_promise));
Construct(&prior.prior.prior.prior.prior.prior.prior.prior.current_promise,
std::move(other.prior.prior.prior.prior.prior.prior.prior.prior
.current_promise));
Construct(&prior.prior.prior.prior.prior.prior.prior.prior.next_factory,
std::move(other.prior.prior.prior.prior.prior.prior.prior.prior
.next_factory));
@ -2772,7 +2790,10 @@ struct SeqState<Traits, P, F0, F1, F2, F3, F4, F5, F6, F7, F8> {
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.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
@ -2797,7 +2818,10 @@ struct SeqState<Traits, P, F0, F1, F2, F3, F4, F5, F6, F7, F8> {
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(SeqState&& other) noexcept
: state(other.state), whence(other.whence) {
DCHECK(state == State::kState0);
Construct(&prior.current_promise, std::move(other.prior.current_promise));
Construct(
&prior.prior.prior.prior.prior.prior.prior.prior.prior.current_promise,
std::move(other.prior.prior.prior.prior.prior.prior.prior.prior.prior
.current_promise));
Construct(
&prior.prior.prior.prior.prior.prior.prior.prior.prior.next_factory,
std::move(other.prior.prior.prior.prior.prior.prior.prior.prior.prior
@ -3387,7 +3411,10 @@ struct SeqState<Traits, P, F0, F1, F2, F3, F4, F5, F6, F7, F8, F9> {
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.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
@ -3416,7 +3443,10 @@ struct SeqState<Traits, P, F0, F1, F2, F3, F4, F5, F6, F7, F8, F9> {
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(SeqState&& other) noexcept
: state(other.state), whence(other.whence) {
DCHECK(state == State::kState0);
Construct(&prior.current_promise, std::move(other.prior.current_promise));
Construct(&prior.prior.prior.prior.prior.prior.prior.prior.prior.prior
.current_promise,
std::move(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,
std::move(other.prior.prior.prior.prior.prior.prior.prior.prior
@ -4072,7 +4102,10 @@ struct SeqState<Traits, P, F0, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10> {
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.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
@ -4105,7 +4138,10 @@ struct SeqState<Traits, P, F0, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10> {
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(SeqState&& other) noexcept
: state(other.state), whence(other.whence) {
DCHECK(state == State::kState0);
Construct(&prior.current_promise, std::move(other.prior.current_promise));
Construct(&prior.prior.prior.prior.prior.prior.prior.prior.prior.prior.prior
.current_promise,
std::move(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,
std::move(other.prior.prior.prior.prior.prior.prior.prior.prior
@ -4829,7 +4865,10 @@ struct SeqState<Traits, P, F0, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11> {
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.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
@ -4866,7 +4905,10 @@ struct SeqState<Traits, P, F0, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11> {
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(SeqState&& other) noexcept
: state(other.state), whence(other.whence) {
DCHECK(state == State::kState0);
Construct(&prior.current_promise, std::move(other.prior.current_promise));
Construct(&prior.prior.prior.prior.prior.prior.prior.prior.prior.prior.prior
.prior.current_promise,
std::move(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,
std::move(other.prior.prior.prior.prior.prior.prior.prior.prior

@ -46,8 +46,8 @@ struct JoinState<Traits, ${",".join(f"P{i}" for i in range(0,n))}> {
}
JoinState& operator=(const JoinState& other) = delete;
JoinState& operator=(JoinState&& other) = delete;
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept : ready(other.ready) {
DCHECK(ready.none());
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION JoinState(JoinState&& other) noexcept {
DCHECK(other.ready.none());
% for i in range(0,n):
Construct(&promise${i}, std::move(other.promise${i}));
% endfor

@ -111,8 +111,8 @@ tail${i}:
}
GPR_ATTRIBUTE_ALWAYS_INLINE_FUNCTION SeqState(const SeqState& other) noexcept : state(other.state), whence(other.whence) {
DCHECK(state == State::kState0);
Construct(&${"prior."*(n-1-i)}current_promise,
other.${"prior."*(n-1-i)}current_promise);
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);
@ -121,8 +121,8 @@ tail${i}:
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);
Construct(&${"prior."*(n-1-i)}current_promise,
std::move(other.${"prior."*(n-1-i)}current_promise));
Construct(&${"prior."*(n-1)}current_promise,
std::move(other.${"prior."*(n-1)}current_promise));
% for i in range(0,n-1):
Construct(&${"prior."*(n-1-i)}next_factory,
std::move(other.${"prior."*(n-1-i)}next_factory));

Loading…
Cancel
Save