Swift Concurrency by Example 第4页
Important: Do not use an actor for your SwiftUI data models 重要提示:请勿将角色用于 SwiftUI 数据模型-Stewed Noodles 资源

Important: Do not use an actor for your SwiftUI data models 重要提示:请勿将角色用于 SwiftUI 数据模型

Swift’s actors allow us to share data in multiple parts of our app without causing problems with concurrency, because they automatically ensure two pieces of code cannot...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri5个月前
70
How to call an async function using async let 如何使用 async let 调用 async 函数-Stewed Noodles 资源

How to call an async function using async let 如何使用 async let 调用 async 函数

Sometimes you want to run several async operations at the same time then wait for their results to come back, and the easiest way to do that is with async let. This lets you start...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri5个月前
70
How to handle concurrency errors in unit tests 如何处理单元测试中的并发错误-Stewed Noodles 资源

How to handle concurrency errors in unit tests 如何处理单元测试中的并发错误

Both Swift Testing and XCTest give us three main options for handling errors in tests: we can consider them immediate failures, we can handle them internally and make our own asser...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri5个月前
70
What’s the difference between await and async let? await 和 async let 有什么区别?-Stewed Noodles 资源

What’s the difference between await and async let? await 和 async let 有什么区别?

Swift lets us perform async operations using both await and async let, but although they both run some async code they don’t quite run the same: await wai...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri5个月前
070
How to force concurrent tests to run on a specific actor 如何强制并发测试在特定actor上运行-Stewed Noodles 资源

How to force concurrent tests to run on a specific actor 如何强制并发测试在特定actor上运行

Swift Testing and XCTest behave differently when it comes to running tests in parallel: unless you say otherwise, Swift Testing will run both synchronous and asynchronous tests on ...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri5个月前
70
Is it efficient to create many tasks? 创建许多任务是否有效?-Stewed Noodles 资源

Is it efficient to create many tasks? 创建许多任务是否有效?

Previously I talked about the concept of thread explosion, which is when you create many more threads than CPU cores and the system struggles to manage them effectively. Howev...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri5个月前
70
How to manipulate an AsyncSequence using map(), filter(), and more 如何使用 map()、filter() 等作 AsyncSequence-Stewed Noodles 资源

How to manipulate an AsyncSequence using map(), filter(), and more 如何使用 map()、filter() 等作 AsyncSequence

AsyncSequence has implementations of many of the same methods that come with Sequence, but how they operate varies: some return a single value that fulfills you...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri5个月前
70
How to control the priority of a task 如何控制任务的优先级-Stewed Noodles 资源

How to control the priority of a task 如何控制任务的优先级

Swift tasks can have a priority attached to them, such as .high or .background, but the priority can also be nil if no specific priority was assigned. This...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri5个月前
70
What’s the difference between a task and a detached task? 任务和分离任务有什么区别?-Stewed Noodles 资源

What’s the difference between a task and a detached task? 任务和分离任务有什么区别?

If you create a new task using the regular Task initializer, your work starts running immediately and inherits the priority of the caller, any task local values, and its ...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri5个月前
70
What’s the difference between Sequence, AsyncSequence, and AsyncStream? Sequence、AsyncSequence 和 AsyncStream 之间有什么区别?-Stewed Noodles 资源

What’s the difference between Sequence, AsyncSequence, and AsyncStream? Sequence、AsyncSequence 和 AsyncStream 之间有什么区别?

Swift provides several ways of receiving a potentially endless flow of data, allowing us to read values one by one, or loop over them using for, while, or similar.Swift ...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri5个月前
60