Concurrency with swift: Structured concurrency | TO THE NEW Blog

General News

Summary

Let us understand with an example: For convenience, we are taking an example of a Dice game with all hard code values and rules to quickly demonstrate the concepts. This is a better way than using GCD/Operations as we get the support of inbuilt error propagation, no more missing completion, and a top-to-the-bottom structured flow of the program. Here we annotated the firstDice and secondDice with the async-let keyword, the program flow will not block and continue to call Int.random async properties in parallel. • None We can see this happening in the where await is the point of suspension blocking the flow until both concurrent tasks return either successfully or with error. In the final word, it is suggested to stick around with Structured concurrency but if required switch to or mix Unstructured Tasks (Normal & Detached) to attain flexibility.

Classifications

industries
No industries detected
applications
Web and Content Management

AskAI Classifications

Labels
Operating Systems Consumer Software Cloud Services

Linked Companies