Swift 5.5 —Acquiring thread locks & sync made easy with Actor isolation

What is a lock?

One of the more difficult problems in developing concurrent programs is dealing with data races. Actors provide a model for building concurrent programs that are free of data races. They do so through data isolation: each actor protects is own instance data, ensuring that only a single thread will access that data at a given time. Actors shift the way of thinking about concurrency from raw threading to actors and put focus on actors “owning” their local state

“Which thread is the first to start isolated access?”

Swift guarantees that only code inside an actor can access the actor’s local state. This guarantee is known as actor isolation.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store