Beyond the basics of structured concurrency

RSS for tag

Discuss the WWDC23 Session Beyond the basics of structured concurrency

View Session

Posts under wwdc2023-10170 tag

4 Posts
Sort by:
Post marked as solved
1 Replies
772 Views
I'm having trouble understanding the use case for discardingTaskGroup. In my app, I want to submit 10 concurrent image upload requests; usually, I'd just fire off 10 unstructured Task {} instances (I'm assuming this is fine) for image in images { Task { do { try await uploadImage(item: item, image: image) } catch { // Handle any errors } } } But then I thought I'd actually like to have a max of ~3 uploads concurrently, where I would prioritize the images that appear to the user earlier first. I know using group.next() in a taskGroup we can await on previous results and add tasks as required. But my task does not return data, rather it performs an action. So, it seems like the new discardingTaskGroup could be a useful API. Task { do { try await withThrowingDiscardingTaskGroup { group in for image in images { group.addTask { try await uploadImage(item: item, image: image) } } } } catch { // Handle any errors } } How can I convert this discarding task group code to only include a max of n tasks running concurrently? And is this even a reasonable use of the new API to begin with? Best, T
Posted
by taychap.
Last updated
.
Post not yet marked as solved
2 Replies
519 Views
From the fantastic video: https://developer.apple.com/videos/play/wwdc2023/10170/?time=298, would you have a downloadable link to that kitchen service project? I'm trying to understand how the method: func handleShift<Orders>(orders: Orders) async throws is called? Because the video shows it to be called this way: for cook in staff.keys { group.addTask { try await cook.handleShift() } } without arguments ... Many thanks!
Posted
by jeffie.
Last updated
.
Post not yet marked as solved
1 Replies
893 Views
I'm working on an iOS project and I'm wondering if it's possible to mix Combine and the new async/await feature in Swift. I want to leverage the power of Combine's reactive programming paradigm along with the simplified asynchronous code flow provided by async/await. Has anyone tried mixing these two approaches in the same project? Are there any known issues or considerations to keep in mind? Are there any best practices or patterns to follow when combining Combine and async/await? I would appreciate any insights or experiences shared. Thank you in advance!
Posted
by Jael19.
Last updated
.
Post not yet marked as solved
1 Replies
590 Views
In the session, it was said that "While actors are great for protecting encapsulated state, we want to modify and read individual properties on our state machine, so actors aren't quite the right tool for this." Could you elaborate it a little more? Is it not recommended to modify and read individual properties in an actor instance?
Posted
by shinzan.
Last updated
.