abstract async shutdown waiting loop
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
0a9b6c136f
commit
9eb99f8070
2 changed files with 13 additions and 8 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue