Skip to main content

fractal/utils/
macros.rs

1//! Collection of macros.
2
3/// Spawn a local future on the default `GMainContext`.
4///
5/// A custom [`glib::Priority`] can be set as the first argument.
6///
7/// [`glib::Priority`]: gtk::glib::Priority
8#[macro_export]
9macro_rules! spawn {
10    ($future:expr) => {
11        gtk::glib::MainContext::default().spawn_local($future)
12    };
13    ($priority:expr, $future:expr) => {
14        gtk::glib::MainContext::default().spawn_local_with_priority($priority, $future)
15    };
16}
17
18/// Spawn a future on the tokio runtime.
19#[macro_export]
20macro_rules! spawn_tokio {
21    ($future:expr) => {
22        $crate::RUNTIME.spawn($future)
23    };
24}