portable-atomic icon indicating copy to clipboard operation
portable-atomic copied to clipboard

Consider providing fallback implementation that uses lock per atomic type

Open taiki-e opened this issue 3 years ago • 1 comments

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.

taiki-e avatar Aug 13 '22 16:08 taiki-e

Alternatively, we might want to allow custom fallback implementation.

taiki-e avatar Aug 13 '22 17:08 taiki-e