-
-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Labels
C-enhancementCategory: A new feature or an improvement for an existing oneCategory: A new feature or an improvement for an existing one
Description
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.
portable-atomic/src/imp/fallback/mod.rs
Lines 1 to 10 in c0a175e
| // Fallback implementation using global locks. | |
| // | |
| // This implementation uses seqlock for global locks. | |
| // | |
| // This is basically based on global locks in crossbeam-utils's `AtomicCell`, | |
| // but seqlock is implemented in a way that does not depend on UB | |
| // (see comments in optimistic_read method in atomic! macro for details). | |
| // | |
| // Note that we cannot use a lock per atomic type, since the in-memory representation of the atomic | |
| // type and the value type must be the same. |
It may be possible to provide something like this as a parameter or from another module.
Metadata
Metadata
Assignees
Labels
C-enhancementCategory: A new feature or an improvement for an existing oneCategory: A new feature or an improvement for an existing one