macro_rules! run_async {
($($body:tt)*) => { ... };
}Expand description
Creates an async execution context in which spawn_local or spawn_with_panic_notify can be used.
When a panic occurs in a background task spawned with spawn_with_panic_notify, the panic will
be propagated to the main task and the execution will be stopped.
Example usage:
use datex_core::run_async;
use datex_core::task::spawn_with_panic_notify;
async fn example() {
run_async! {
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
spawn_with_panic_notify(async {
// Simulate a panic
panic!("This is a test panic");
});
}
}