Home / Apple / Michael Tsai – Blog – Introduction to Swift Atomics

Michael Tsai – Blog – Introduction to Swift Atomics



Karoy Lorentey (Hacker News):

I’m pleased to announce Swift Atomics, a new open source package that enables direct use of low-level atomic-level operations in Swift code. The goal of this library is to enable fearless system programmers to start building synchronization constructs (such as concurrent data structures) directly in Swift.

[…]

This is enabled by SE-0282, a recently accepted Swift Evolution proposal that explicitly adopted a C / C ++ -style memory model for Swift, and (informally) described how regular Swift code works with nuclear operations. In fact, most of the APIs in this new package come from previous incarnations of the SE-0282 proposal: they were originally developed by an extremely productive collaborative effort on the Evolution Forum.

[…]

Nuclear access is implemented in the form of dedicated nuclear storage representations that are kept separate from the corresponding common (non-nuclear) type. (For example, the actual integer value behind the counter above is not directly available.)

[…]

All nuclear operations exposed by this package have guaranteed lock-free implementations. Freedom of locking means that nuclear operations do not block ̵

1; they never have to wait for the progress of another thread to complete their own task.

Earlier:

Simultaneity iOS iOS 14 Language design Mac macOS 10.15 Catalina Memory Management Open source Programming fast programming language

Stay up to date by subscribing to the RSS feed for comments for this post.


Source link