kithara-platform 0.0.1-alpha2

Cross-platform primitives (sync, time, thread) for native and wasm32.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
/// Returns a process-wide mutex that serializes mutations of `std::env`
/// across threads.
///
/// `std::env::set_var` and `remove_var` are not thread-safe in the
/// presence of concurrent reads from other threads. Code that mutates
/// the process environment (test setup, startup-time configuration,
/// `#[kithara::test]` proc-macro env-guard) should hold this lock
/// across the mutation to prevent races.
#[must_use]
pub fn env_mutation_lock() -> &'static std::sync::Mutex<()> {
    static LOCK: std::sync::OnceLock<std::sync::Mutex<()>> = std::sync::OnceLock::new();
    LOCK.get_or_init(|| std::sync::Mutex::new(()))
}