| Crates.io | region_local |
| lib.rs | region_local |
| version | 1.0.2 |
| created_at | 2025-03-08 06:05:37.5334+00 |
| updated_at | 2025-09-22 14:56:05.23756+00 |
| description | Isolated variable storage per memory region, similar to `thread_local_rc!` |
| homepage | |
| repository | https://github.com/folo-rs/folo |
| max_upload_size | |
| id | 1584122 |
| size | 106,120 |
On many-processor systems with multiple memory regions, there is an extra cost associated with accessing data in physical memory modules that are in a different memory region than the current processor:
This crate provides the capability to create static variables that maintain separate storage per memory region. This may be useful in circumstances where state needs to be shared but only within each memory region (e.g. because you intentionally want to avoid the overhead of cross-memory-region transfers and want to isolate the data sets).
Think of this as an equivalent of thread_local_rc!, except operating on the memory region boundary
instead of the thread boundary.
// `RegionLocalExt` provides required extension methods on region-local
// static variables, such as `with_local()` and `set_local()`.
use region_local::{RegionLocalExt, region_local};
region_local!(static FAVORITE_COLOR: String = "blue".to_string());
FAVORITE_COLOR.with_local(|color| {
println!("My favorite color is {color}");
});
FAVORITE_COLOR.set_local("red".to_string());
More details in the package documentation.
This is part of the Folo project that provides mechanisms for high-performance hardware-aware programming in Rust.