Paul Krill
Editor at Large

Apple proposes actor model for Swift concurrency

news
Mar 19, 20212 mins

Swift language proposal would add actors as a way to prevent data races and other common bugs in concurrent programming.

thread weave spools connected rotate spin
Credit: Thinkstock

Apple has published a proposal to add an actor model to the Swift programming language. The goal is to provide a mechanism that prevents data races in the Swift concurrency model.

A Swift evolution proposal in the active review stage, posted on GitHub, notes that the actor model would provide the ability to use shared mutable state while providing static detection of data races and other common concurrency bugs.

An actor is a reference type (introduced by the keyword actor :) that protects access to its mutable state. In response to messages, an actor can make local decisions, send more messages, create more actors, and decide how to respond to the next message received. Actors can modify their own private state but only affect each other indirectly through messaging, thus eliminating the need for lock-based synchronization.

A concurrency roadmap for the Swift language published last fall included a proposal for actors and actor isolation. A structured concurrency proposal for Swift introduces concurrent tasks and provides data race safety for functions and closures. While this model is suitable for some design patterns, including parallel maps and concurrent callback patterns, it is limited to working with state captured by closures. Although Swift includes classes that provide a mechanism for declaring mutable state that is shared across a program, classes are difficult to use within concurrent programs.

The actor proposal is set to be reviewed until March 29. The review process was opened on March 15.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author