new file: Makefile
new file: TODO.md modified: src/config.rs modified: src/detect.rs modified: src/diagnose.rs new file: src/gui.rs modified: src/main.rs modified: src/service.rs modified: src/setup.rs modified: src/tray.rs new file: src/util.rs new file: umutray.desktop
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
use iced::futures::channel::oneshot;
|
||||
|
||||
/// Run a blocking closure on a thread pool thread and await its result.
|
||||
/// Used to offload blocking work (HTTP, disk, process spawning) without
|
||||
/// stalling the iced event loop.
|
||||
pub async fn async_blocking<T, F>(f: F) -> T
|
||||
where
|
||||
T: Send + 'static,
|
||||
F: FnOnce() -> T + Send + 'static,
|
||||
{
|
||||
let (tx, rx) = oneshot::channel();
|
||||
std::thread::spawn(move || {
|
||||
let _ = tx.send(f());
|
||||
});
|
||||
rx.await.expect("blocking task panicked")
|
||||
}
|
||||
Reference in New Issue
Block a user