lavina/src/util/mod.rs

27 lines
600 B
Rust
Raw Normal View History

2023-02-07 15:21:00 +00:00
use crate::prelude::*;
pub mod http;
2023-02-04 01:01:49 +00:00
pub mod table;
pub mod telemetry;
2023-02-12 12:15:31 +00:00
#[cfg(test)]
pub mod testkit;
2023-02-07 15:21:00 +00:00
pub struct Terminator {
2023-02-14 22:49:56 +00:00
signal: Promise<()>,
2023-02-07 15:21:00 +00:00
completion: JoinHandle<Result<()>>,
}
impl Terminator {
2023-02-14 22:49:56 +00:00
pub fn from_raw(signal: Promise<()>, completion: JoinHandle<Result<()>>) -> Terminator {
2023-02-07 15:21:00 +00:00
Terminator { signal, completion }
}
pub async fn terminate(self) -> Result<()> {
match self.signal.send(()) {
Ok(()) => {}
Err(_) => log::error!("Termination channel is dropped"),
}
self.completion.await??;
Ok(())
}
}