portable-atomic
portable-atomic copied to clipboard
Consider providing fallback implementation that uses lock per atomic type
The current lock-based fallback uses global locking for memory layout compatibility with standard library atomic types. This is the approach also used in C++ std::atomic, atomic-rs, and crossbeam AtomicCell, which is not so bad, but not best from a point of view of performance.
https://github.com/taiki-e/portable-atomic/blob/c0a175e21d33c2e14a2987b5f8d775d9714e7f71/src/imp/fallback/mod.rs#L1-L10
It may be possible to provide something like this as a parameter or from another module.
Alternatively, we might want to allow custom fallback implementation.