mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-16 04:30:38 +00:00
Revert "Revert "use tokio::sync:⌚:Receiver::wait_for""
This reverts commit eaf270c648.
This commit is contained in:
@@ -1704,15 +1704,12 @@ impl Tenant {
|
||||
///
|
||||
/// This function is not cancel-safe!
|
||||
pub async fn set_stopping(&self) {
|
||||
// Get the rx before checking state inside send_if_modified.
|
||||
// This way, when we later rx.changed().await, we won't have missed
|
||||
// any state changes.
|
||||
// `Activating` is a transient state during which no external state transitions are supported.
|
||||
let mut rx = self.state.subscribe();
|
||||
while *rx.borrow() == TenantState::Activating {
|
||||
rx.changed()
|
||||
.await
|
||||
.expect("we're a method on Tenant, so, we're keeping self.state alive here");
|
||||
}
|
||||
rx.wait_for(|state| state != TenantState::Activating)
|
||||
.await
|
||||
.expect("cannot drop self.state while on a &self method");
|
||||
|
||||
let mut stopping = false;
|
||||
self.state.send_modify(|current_state| {
|
||||
match current_state {
|
||||
@@ -1750,12 +1747,12 @@ impl Tenant {
|
||||
}
|
||||
|
||||
pub async fn set_broken(&self, reason: String) {
|
||||
// `Activating` is a transient state during which no external state transitions are supported.
|
||||
let mut rx = self.state.subscribe();
|
||||
while *rx.borrow() == TenantState::Activating {
|
||||
rx.changed()
|
||||
.await
|
||||
.expect("we're a method on Tenant, so, we're keeping self.state alive here");
|
||||
}
|
||||
rx.wait_for(|state| state != TenantState::Activating)
|
||||
.await
|
||||
.expect("cannot drop self.state while on a &self method");
|
||||
|
||||
self.state.send_modify(|current_state| {
|
||||
match *current_state {
|
||||
TenantState::Activating => {
|
||||
|
||||
Reference in New Issue
Block a user