Skip to main content

egui_async/
lib.rs

1#![cfg_attr(not(doctest), doc = include_str!("../README.md"))]
2#![forbid(unsafe_code)]
3#![deny(missing_docs)]
4
5pub mod bind;
6
7pub use bind::{Bind, State, StateWithData};
8
9#[cfg(not(target_family = "wasm"))]
10pub use bind::set_global_runtime;
11
12#[cfg(feature = "egui")]
13pub mod egui;
14
15#[cfg(feature = "egui")]
16pub use egui::{EguiAsyncPlugin, UiExt};
17
18/// A macro to run initialization code only once, even in the presence of multiple threads.
19/// Returns `true` if the code was executed in this call, `false` otherwise.
20#[macro_export]
21macro_rules! run_once {
22    { $($tokens:tt)* } => {{
23        static INIT_ONCE_BLOCK_: std::sync::Once = std::sync::Once::new();
24        let mut init_once_block_executed = false;
25        INIT_ONCE_BLOCK_.call_once(|| {
26            $($tokens)*
27            init_once_block_executed = true;
28        });
29        init_once_block_executed
30    }};
31}