forked from lavina/lavina
27 lines
600 B
Rust
27 lines
600 B
Rust
use crate::prelude::*;
|
|
|
|
pub mod http;
|
|
pub mod table;
|
|
pub mod telemetry;
|
|
#[cfg(test)]
|
|
pub mod testkit;
|
|
|
|
pub struct Terminator {
|
|
signal: Promise<()>,
|
|
completion: JoinHandle<Result<()>>,
|
|
}
|
|
impl Terminator {
|
|
pub fn from_raw(signal: Promise<()>, completion: JoinHandle<Result<()>>) -> Terminator {
|
|
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(())
|
|
}
|
|
}
|