atomic_state/
lib.rs

1#![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md"))]
2pub mod prelude;
3
4pub mod flag;    pub use flag::Flag;
5pub mod state;   pub use state::{ State, StateGuard };
6
7pub use once_cell::{ self, sync::Lazy };
8pub use arc_swap::{ self, ArcSwap };
9
10/// Initializes a static variable by 'once_cell::Lazy'
11#[macro_export]
12macro_rules! lazy {
13    ($e:expr) => {{
14        ::atomic_state::Lazy::new(|| { $e })
15    }}
16}
17
18/// Initializes a static 'Flag' by 'once_cell::Lazy'
19#[macro_export]
20macro_rules! lazy_flag {
21    ($e:expr) => {{
22        ::atomic_state::Lazy::new(|| ::atomic_state::Flag::new($e))
23    }}
24}
25
26/// Initializes a static 'State' by 'once_cell::Lazy'
27#[macro_export]
28macro_rules! lazy_state {
29    ($e:expr) => {{
30        ::atomic_state::Lazy::new(|| ::atomic_state::State::new($e))
31    }}
32}