Crate once

Crate once 

Source
Expand description

§Once Crate

The once crate provides thread-safe data structures that are designed for insert-once semantics, making them particularly useful for concurrent programming scenarios where data is computed once and then read many times. Values can be mutated through exclusive (&mut) references, but new entries can only be inserted, never removed.

§Key Components

  • OnceVec: A thread-safe vector that allows pushing elements in a way that ensures they are safely visible to other threads.
  • OnceBiVec: A bidirectional vector built on top of OnceVec that supports negative indices.
  • MultiIndexed: A multi-dimensional array that allows efficient storage and retrieval of values using multi-dimensional coordinates.
  • Grove and TwoEndedGrove: Specialized collections that support the implementation of the other data structures.

§Concurrency Support

This crate is designed with concurrency in mind and uses atomic operations and locks to ensure thread safety. It can be used with the concurrent feature to enable parallel operations via the rayon crate.

§Testing with Loom

The crate supports testing with the loom concurrency testing framework. Loom tests can be run with:

RUSTFLAGS="--cfg loom" cargo test --release --features loom -- loom

Re-exports§

pub use grove::Grove;
pub use grove::TwoEndedGrove;
pub use multiindexed::MultiIndexed;
pub use once::OnceBiVec;
pub use once::OnceBiVecIter;
pub use once::OnceVec;
pub use once::OnceVecIter;

Modules§

grove
multiindexed
once
std_or_loom 🔒
This module provides a way to use the standard library or loom’s types in a unified way, depending on the loom cfg flag.
write_once