use std::sync::atomic::Ordering;
use futures_util::future::join_all;
use crate::action::action_impl;
#[action_impl]
impl Action for crate::action::Shutdown {
type Future = ShutdownFuture;
async fn execute(self) -> () {
if !self.immediate {
let pending = self
.client
.inner
.shutdown
.pending_drops
.lock()
.unwrap()
.extract();
join_all(pending).await;
}
if !self.client.inner.shutdown.executed.load(Ordering::SeqCst) {
self.client.end_all_sessions().await;
}
self.client.inner.topology.updater().shutdown().await;
self.client
.inner
.shutdown
.executed
.store(true, Ordering::SeqCst);
}
}