ferro_thread_local
macro · ferroui-system · v0.5.0
macro_rules! ferro_thread_local
Declares thread-local variables: std::thread_local! on targets with
thread-local statics, a slot of the table of the thread on Android (see
the module).
use std::cell::{Cell, RefCell};
ferroui_system::ferro_thread_local! {
static COUNT: Cell<u32> = const { Cell::new(0) };
static NAMES: RefCell<Vec<String>> = RefCell::new(Vec::new());
}
COUNT.set(COUNT.get() + 1);
NAMES.with_borrow_mut(|names| names.push("one".to_owned()));
assert_eq!(COUNT.get(), 1);
New code of the workspace declares its thread-local variables with this
macro and never with thread_local! (the conventions job checks it).
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.