abstract async shutdown waiting loop

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-12-29 02:21:22 +00:00 committed by strawberry
parent 0a9b6c136f
commit 9eb99f8070
2 changed files with 13 additions and 8 deletions

View file

@ -1,5 +1,8 @@
use std::{
sync::atomic::{AtomicBool, Ordering},
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
time::SystemTime,
};
@ -102,6 +105,13 @@ impl Server {
Ok(())
}
#[inline]
pub async fn until_shutdown(self: Arc<Self>) {
while self.running() {
self.signal.subscribe().recv().await.ok();
}
}
#[inline]
pub fn runtime(&self) -> &runtime::Handle {
self.runtime