#atomic #lock-free

atomic_cell

Lock-free thread-safe mutable memory locations

2 unstable releases

0.2.0 Oct 20, 2022
0.1.0 Oct 16, 2015

#516 in Concurrency

Download history 4/week @ 2023-10-26 3/week @ 2023-11-02 3/week @ 2023-11-09 5/week @ 2023-11-16 2/week @ 2023-11-23 11/week @ 2023-11-30 1/week @ 2023-12-07 3/week @ 2023-12-14 6/week @ 2023-12-21 4/week @ 2023-12-28 2/week @ 2024-01-04 4/week @ 2024-01-11 4/week @ 2024-01-18 77/week @ 2024-01-25 6/week @ 2024-02-01 7/week @ 2024-02-08

96 downloads per month

MIT license

76KB
933 lines

Atomic-Cell

Test Status Crate API

A crate for lock-free, thread-safe, mutable memory locations.


lib.rs:

This crate provides a thread-safe mutable memory location called AtomicCell.

This type is equivalent to Cell, except it can also be shared among multiple threads.

How it Works

When constructing an AtomicCell, callers select an AtomicStorage implementation that will fit the data they wish to store. (e.g. AtomicU8 can be used to hold a #[repr(u8)] enum)

Under the hood, the desired type is transmuted to the corresponding base type of the storage, and atomic operations are executed on the storage.

The result is that the user should be able to seamlessly interact with the AtomicCell almost as if it were a native atomic.

Two implementations are defined generic and macros. The generic implementation relies on the AtomicStorage trait, whereas the macros implementation relies on the bare functions. This enables the macros implementation to have slightly more const functions in stable rust.

Dependencies

~215KB