pull/35413/head
Craig Tiller 1 year ago
parent 58e6c4214b
commit 9f20f34523
  1. 10
      src/core/lib/promise/party.h

@ -102,7 +102,7 @@ class PartySyncUsingAtomics {
template <typename F> template <typename F>
GRPC_MUST_USE_RESULT bool RunParty(F poll_one_participant) { GRPC_MUST_USE_RESULT bool RunParty(F poll_one_participant) {
uint64_t prev_state; uint64_t prev_state;
++iteration_; iteration_.fetch_add(1, std::memory_order_relaxed);
for (;;) { for (;;) {
// Grab the current state, and clear the wakeup bits & add flag. // Grab the current state, and clear the wakeup bits & add flag.
prev_state = state_.fetch_and(kRefMask | kLocked | kAllocatedMask, prev_state = state_.fetch_and(kRefMask | kLocked | kAllocatedMask,
@ -146,7 +146,7 @@ class PartySyncUsingAtomics {
(prev_state & (kRefMask | kAllocatedMask | kLocked)) | (prev_state & (kRefMask | kAllocatedMask | kLocked)) |
wake_after_poll_, wake_after_poll_,
std::memory_order_acq_rel, std::memory_order_acquire)) { std::memory_order_acq_rel, std::memory_order_acquire)) {
++iteration_; iteration_.fetch_add(1, std::memory_order_relaxed);
wake_after_poll_ = 0; wake_after_poll_ = 0;
} }
} }
@ -202,7 +202,9 @@ class PartySyncUsingAtomics {
GRPC_MUST_USE_RESULT bool ScheduleWakeup(WakeupMask mask); GRPC_MUST_USE_RESULT bool ScheduleWakeup(WakeupMask mask);
void WakeAfterPoll(WakeupMask mask) { wake_after_poll_ |= mask; } void WakeAfterPoll(WakeupMask mask) { wake_after_poll_ |= mask; }
uint32_t iteration() const { return iteration_; } uint32_t iteration() const {
return iteration_.load(std::memory_order_relaxed);
}
private: private:
bool UnreffedLast(); bool UnreffedLast();
@ -243,7 +245,7 @@ class PartySyncUsingAtomics {
static constexpr uint64_t kOneRef = 1ull << kRefShift; static constexpr uint64_t kOneRef = 1ull << kRefShift;
std::atomic<uint64_t> state_; std::atomic<uint64_t> state_;
uint32_t iteration_ = 0; std::atomic<uint32_t> iteration_{0};
WakeupMask wake_after_poll_ = 0; WakeupMask wake_after_poll_ = 0;
}; };

Loading…
Cancel
Save