There is a proposal to add an actor model to Swift programming language, which the actor proposal review process was opened on March 15 and will be reviewed until March 29.

While the actor model would offer developers the ability to use shared mutable state, with static detection of data races and other common concurrency bugs. Apple had earlier implemented Swift Atomics, which is an open source package that makes it possible to build synchronization constructs, like concurrent data structures, directly within the Swift programming language.

Now, the actor model is suitable for most design patterns, like parallel maps and concurrent callback patterns, albeit it is limited to working with state captured by closures. Swift includes classes that offers a mechanism for declaring mutable state shared across a program, although classes are difficult to use within concurrent programs.

What is an Actor?



A reference type introduced by the keyword actor :) which protects access to its mutable state is known as an actor. And with reference to messaging, an actor can take local decisions, send messages, create more actors, and decide on how to respond to next message received.



Also, Actors can modify their own private state, but only affect each other indirectly via messaging, therefore eliminating the need for any lock-based synchronization.

Why An Actor Model of Concurrency for the Swift Programming Language?



The concurrency roadmap for the Swift language made available by apple last fall included a proposal for actors and actor isolation, with a structured concurrency proposal for Swift that introduces concurrent tasks and offers data race safety for functions and closures.

Despite the rise in popularity of the Swift programming language, it lacks the facilities for true concurrent programming. However, there is an extension to the language which enables access to said concurrent capabilities and offers an api for supporting these interactions.

But the adoption of the ACTOR model of concurrent computation shows that it can be successfully incorporated into the language. And the early findings on prototype implementation suggests a general design pattern for the implementation of the ACTOR model in the Swift programming language.

Proposal for Actor Model of Concurrency in Swift Programming Language

There is a proposal to add an actor model to Swift programming language, which the actor proposal review process was opened on March 15 and will be reviewed until March 29.

While the actor model would offer developers the ability to use shared mutable state, with static detection of data races and other common concurrency bugs. Apple had earlier implemented Swift Atomics, which is an open source package that makes it possible to build synchronization constructs, like concurrent data structures, directly within the Swift programming language.

Now, the actor model is suitable for most design patterns, like parallel maps and concurrent callback patterns, albeit it is limited to working with state captured by closures. Swift includes classes that offers a mechanism for declaring mutable state shared across a program, although classes are difficult to use within concurrent programs.

What is an Actor?



A reference type introduced by the keyword actor :) which protects access to its mutable state is known as an actor. And with reference to messaging, an actor can take local decisions, send messages, create more actors, and decide on how to respond to next message received.



Also, Actors can modify their own private state, but only affect each other indirectly via messaging, therefore eliminating the need for any lock-based synchronization.

Why An Actor Model of Concurrency for the Swift Programming Language?



The concurrency roadmap for the Swift language made available by apple last fall included a proposal for actors and actor isolation, with a structured concurrency proposal for Swift that introduces concurrent tasks and offers data race safety for functions and closures.

Despite the rise in popularity of the Swift programming language, it lacks the facilities for true concurrent programming. However, there is an extension to the language which enables access to said concurrent capabilities and offers an api for supporting these interactions.

But the adoption of the ACTOR model of concurrent computation shows that it can be successfully incorporated into the language. And the early findings on prototype implementation suggests a general design pattern for the implementation of the ACTOR model in the Swift programming language.

No comments