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.
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.
Really good example, thank you! I learned a lot and think more in this new async/await way now instead of thinking in queues 😁
Great explanation and good catch about Actor reentrancy.
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.
This is amazing, thank you for the explanation 🙏🏻
Can we have a video on task cancellation please?
Noted!
Great content here. Thanks for sharing. this trick actually applies to a lot of problems.
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!
Thanks @DonnyWalsdev! Great example and well explained.
Subtle and complex! Thank you.