|Swift 5.5 Adds Concurrency Support|
|Written by Kay Ewbank|
|Tuesday, 05 October 2021|
Swift 5.5 has been released with new features for asynchronous code and concurrency including async/await, structured concurrency, and Actors. Swift is Apple's language that was originally developed as an alternative language to Objective C.
The improvements to Swift 5.5 start with support for coroutine models to make it easier to write asynchronous code. The developers say a lot of Swift code involves async programming using closures and completion handlers, but these APIs are hard to use. To overcome this, the new coroutine model means functions can opt into being async, so developers can have asynchronous operations using the normal control-flow mechanisms. The compiler is responsible for translating an asynchronous function into an appropriate set of closures and state machines.
Another improvement is the addition of structured concurrency. This uses the async/await improvements, and adds the ability to execute, cancel, and monitor concurrent operations in Swift. The asynchronous functions introduced with async can give up the thread on which they are executing at any given suspension point, but they don't actually introduce concurrency. This has been added separately to provide a way to support concurrent execution of asynchronous code. Structured concurrency relies on tasks being split into high-level tasks and their child component tasks.
Other improvements add support for creating and awaiting child tasks using the simple syntax async let as an alternative to task groups; and support for package collections to the Swift package manager, SwiftPM. A package collection is a curated list of packages and associated metadata. SwiftPM now lets you subscribe to these collections, search them via the swift package-collection command-line interface, and makes their contents accessible to any clients of libSwiftPM.
Swift 5.5 is available now.
or email your comment to: email@example.com
|Last Updated ( Tuesday, 05 October 2021 )|