Concurrency Games: async/await in Swift 5.5
--
For this article context term concurrency refer to the common combination of asynchronous and parallel code.
Parallel code means multiple pieces of code run simultaneously — for example, a computer with a four-core processor can run four pieces of code at the same time, with each core carrying out one of the tasks.
Concurrency = async + parallel Code (not time sharing) for this article
Async Functions:
Sync function can not call async function directly, Async functions can call sync or async funtions both.
Calling Asynchronous Functions in Parallel:
Calling an asynchronous function with await runs only one piece of code at a time. While the asynchronous code is running, the caller waits for that code to finish before moving on to run the next line of code.
To call an asynchronous function and let it run in parallel with code around it, use async let
Output :
P.S. : Upto XCode 13.0 this features is available iOS 15.0 and above.
Follow me Rahul Goel for more updates.