atomic-state 0.1.5

This library provides a static asynchronous data that can be accessed safely and concurrently from any part of your program
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use atomic_state::prelude::*;

static IS_ACTIVE: Lazy<Flag> = lazy_flag!(false);

#[tokio::main]
async fn main() {
    assert_eq!(*IS_ACTIVE, false);
    assert!(IS_ACTIVE.is_false());

    IS_ACTIVE.set(true);
    assert_eq!(*IS_ACTIVE, true);

    IS_ACTIVE.swap(false).await;
    assert_eq!(*IS_ACTIVE, false);
}