« first day  last day (15 days later) » 

09:20
Thank you so much for the explanations. This is extremely helpful for my understanding
You can create another task in task using Task.init or Task.detached. - Yeah but why would one do that ? Given all we've said so far do you have a concrete example when one would to that - to me it sounds like an antipattern
09:36
"create another task in task using Task.init or Task.detached. - Yeah but why would one do that " - sometime you do not have any other choice, however, this should be really last choice, because when you do so, you leave the world of structured concurrency.
and you have to manage the created tasks manually
nobody sets isCancelled for those, if the task that created them is cancelled
they can survive the task that created them
when you stick with structured concurrency, and child tasks, you get this for free
I wrote "async let something = await thisIsWhatRunsInTheChildTask()", but it is not correct. Correct is async let something = thisIsWhatRunsInTheChildTask(), and then, anytime later, await something
declaration is func thisIsWhatRunsInTheChildTask() async { ... }
finally, you can see quite often creating new (unstructured) task in a task, simply because all this topic is difficult, and many developers do not fully understand it, and cannot handle this dangerous (and powerful) weapon.... :)
 
2 hours later…
11:20
I guess the most important thing for me from this thread as you've outlined a few times is that a task being a child of another (that is achieved by async let or taskGroup) is a different concept from what the documentation says about Task - "the task created by Task.init(priority:operation:) inherits the priority and actor context of the caller".
When we talk about structured concurrency we talk about a tree of tasks. When we talk about creating a new task with init we talk about inheriting actor context.
The fact that a task created with .init inherits the actor context of the caller DOES NOT and WILL NOT mean that the task is a child of 'some-up-the-stack' potential parent task.
I have read a few books and numerous articles and I can see there is this cloud of confusion everywhere on how things work and how we should be using them. WWDC is super vague, the proposals are very detailed with theory that a normal user has difficult time processing it.
We hear everywhere about task trees and so on but then Task created with init inside another task is not a child of its parent? Task created with async let (that the user has no notion of) however is a child of its parent - Its very confusing and in my opinion the Swift team has made redundant syntax sugars which are cool to show off in WWDC but are hard to understand when you start working with them
Anyways I appreciate your time very much, will make sure I spread the knowledge with my team. Best of luck and happy holidays ( :
Merry Christmas!

« first day  last day (15 days later) »