Concurrency model proposed for Swift language
6 November 2020 | 0
Plans are afoot to outfit Apple’s Swift language with a ‘first-class’ concurrency model. The goal is to make concurrent programming in Swift efficient, safe, and convenient, according to the roadmap published at forums.swift.org.
Swift concurrency is intended to prevent data races on mutable state by default, through the implementation of asynchronous functions and actors. These will be introduced in two phases, first by bringing in the ability to create async functions and actors, and then by enforcing full actor isolation.
The end state of the proposed changes would do the following:
- Eliminate data races and deadlocks in the same way Swift eliminates memory unsafety
- Make asynchronous programming convenient and clear at its point of use
- Provide a standard set of language tools and techniques that developers can follow
- Improve performance of asynchronous code through better knowledge at compile time
The introduction of these features would span multiple Swift releases. The first phase, introducing the
async syntax and actor types, would allow users to organise code around actors in such a way that would reduce but not eliminate data races. The second phase, which would enforce full actor isolation, would eliminate data races. It also would offer features allowing efficient, ergonomic interoperation of actors needed to make the isolation practical.
Specific proposals for the first phase include:
- Introduction of a coroutine-based async/await model to Swift
- Task API and structured concurrency, introducing the concept of a task to the standard library
- Actors and actor isolation, describing the actor model that provides state isolation for concurrent programs
- Concurrency interoperability with Objective-C, Swift’s predecessor language
- Async handlers, introducing the ability to declare a synchronous actor function as an asynchronous handler
IDG News Service
Is this an area of interest? Tailored training for IT Professionals
The Irish Computer Society provides members with the necessary qualifications, skills and training needed to succeed and excel within the profession.
Upcoming courses which may be of interest include:
- Certificate in Business Analysis – offers academic accreditation for business analysts through the use of proven business analysis techniques. Up to 100% funding available
- Managing a Data Breach – one-day advanced course covers the main factors which may lead to a data breach and what process should be followed in the event of occurrence of such.
- Free Web Accessibility Training – for anyone who creates web content and electronic documents, especially those in the public sector or those writing content for websites.
- Blockchain & new media webinar – Expert presentations and Q&A will discuss decentralised approaches to new media and broadcasting.