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::AtomFlag;
5pub mod state;   pub use state::{ AtomState, AtomStateGuard };
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 'AtomFlag' by 'once_cell::Lazy'
19#[macro_export]
20macro_rules! lazy_flag {
21    ($e:expr) => {{
22        ::atomic_state::Lazy::new(|| AtomFlag::new($e))
23    }}
24}
25
26/// Initializes a static 'AtomState' by 'once_cell::Lazy'
27#[macro_export]
28macro_rules! lazy_state {
29    ($e:expr) => {{
30        ::atomic_state::Lazy::new(|| AtomState::new($e))
31    }}
32}