This is a great one. I was actually expecting to see another dictionary variable that keeps track of running tasks. But the enum with associated type looks so much better.
I avoided actors at the beginning because they were repentant in ways that broke my mental model. After watching apple’s concurrency video with the islands several times the phrase that clicked was that the serialization mechanism was tasks. So, rather than doing complex threading models or queuing work to run in the background I just create tasks from the UI and call actor methods for background work. This usage reduces the reentrancy issues as the control flow is in single tasks. If I need to spawn long running background tasks (detached) this will again raise the reentrancy issues.
Thank you for the great explanation. Another example that Swift concurrency should be used sparingly and designed properly, supplied with comment to explain "what is going on" without the believes that "this is just amazing and compiler will solve everything". By the way: "Doing one thing at a time but not atomically" should be printed on a t-shirt :) I am wondering what if an actor contain just private cache, async getter to read from the cache and sync setter to write to the cahe, will it behave as an atomic storage?
Great explanation and good catch about Actor reentrancy.
This is a great one. I was actually expecting to see another dictionary variable that keeps track of running tasks. But the enum with associated type looks so much better.
Thanks!
Really good example, thank you! I learned a lot and think more in this new async/await way now instead of thinking in queues 😁
I avoided actors at the beginning because they were repentant in ways that broke my mental model. After watching apple’s concurrency video with the islands several times the phrase that clicked was that the serialization mechanism was tasks. So, rather than doing complex threading models or queuing work to run in the background I just create tasks from the UI and call actor methods for background work. This usage reduces the reentrancy issues as the control flow is in single tasks. If I need to spawn long running background tasks (detached) this will again raise the reentrancy issues.
Subtle and complex! Thank you.
Thank you for the great explanation. Another example that Swift concurrency should be used sparingly and designed properly, supplied with comment to explain "what is going on" without the believes that "this is just amazing and compiler will solve everything". By the way: "Doing one thing at a time but not atomically" should be printed on a t-shirt :) I am wondering what if an actor contain just private cache, async getter to read from the cache and sync setter to write to the cahe, will it behave as an atomic storage?
Great content here. Thanks for sharing. this trick actually applies to a lot of problems.
This is amazing, thank you for the explanation 🙏🏻
Can we have a video on task cancellation please?
Noted!
Thanks @DonnyWalsdev! Great example and well explained.