Swift Atomics aims to allow system programmers to write synchronization constructs directly in Swift.

Swift Atomics provides developers aiming to build sophisticated, high-level, multi-threaded constructs, such as lock-free data structure, the opportunity to do so directly in Swift. Previously, to use atomic operations in Swift, developers had to usually resort to external libraries implemented in a different language.

While striving to make atomic operations easier to use for Swift developers, Swift does not remove the inherent risk with any program using low-level synchronization primitives and is not meant to be a library for every Swift developer out there.

The Atomics package provides carefully considered APIs for atomic operations that follows established design principles for Swift APIs. However, the underlying operations work on a very low level of abstraction. Atomics – even more than other low-level concurrency constructs – are notoriously difficult to use correctly.

So, most Swift developers will continue to use Grand Central Dispatch and queues for their asynchronous code.

#ios #macos #system programming #swift #concurrency #development #news

Swift Atomics Enables First-Class Atomic Operations in Swift
1.35 GEEK