feat(client): adopt an asynchronous Tokio runtime for the client frontend

This commit is contained in:
Nils Andreas Svee committed 2026-10-05 21:01:54 +07:00
1 parent 1f7df1ebc9
commit 66abb792ce
8 files changed
+355 -331

No files matched your search

+12
View File
@@ -1,10 +1,22 @@
#[cfg(any(feature = "server", feature = "tui"))]
use std::sync::{
atomic::{AtomicBool, Ordering},
Arc,
};
#[cfg(any(feature = "server", feature = "tui"))]
pub fn install_signal_handler(shutdown_requested: Arc<AtomicBool>) -> Result<(), ctrlc::Error> {
ctrlc::set_handler(move || {
shutdown_requested.store(true, Ordering::Relaxed);
})
}
/// Preserve ctrlc's SIGINT/SIGTERM policy while waking the async client.
#[cfg(feature = "client")]
pub fn install_async_signal_handler() -> Result<tokio::sync::watch::Receiver<bool>, ctrlc::Error> {
let (shutdown, receiver) = tokio::sync::watch::channel(false);
ctrlc::set_handler(move || {
shutdown.send_replace(true);
})?;
Ok(receiver)
}