Low-level atomic operations for Swift
open sourceApache-2.0free
Swift Atomics is Apple's package of low-level atomic operations for Swift, for integers, pointers and other types (ManagedAtomic, UnsafeAtomic), so the same memory can be read and updated safely from several threads. As of Swift 6.0 it's largely superseded by the standard library's Atomic type in the Synchronization module (SE-0410); existing code keeps working, and its maintainers recommend migrating when convenient.
Problems it solves
- share a counter between threads in Swift without locks
- lock-free data structures in Swift before Swift 6
- atomic operations on Swift 5 toolchains
Features
- atomic integers, pointers and other types
- ManagedAtomic and UnsafeAtomic
- memory orderings for lock-free code
Limitations
- Largely superseded by the standard library's Atomic (Synchronization module) as of Swift 6.0; its maintainers recommend migrating.1
Alternatives
The same job
These do what Swift Atomics does.
- Queuer Queue manager for Swift on OperationQueue and GCD
