Checkpoint

This commit is contained in:
Antonio Scandurra 2023-10-04 17:48:28 +02:00
parent bc1801fb03
commit f9646208e9
4 changed files with 117 additions and 33 deletions

View file

@ -27,7 +27,15 @@ where
F: FnOnce() -> R + Send + 'static,
R: Send + 'static,
{
spawn_on_main(dispatcher, move || async move { func() })
let (tx, rx) = oneshot::channel();
if dispatcher.is_main_thread() {
let _ = tx.send(func());
} else {
let _ = spawn_on_main(dispatcher, move || async move {
let _ = tx.send(func());
});
}
async move { rx.await.unwrap() }
}
/// Enqueues the given closure to be run on the application's event loop. The