Swift Concurrency by Example 第5页
How to run tasks using SwiftUI’s task() modifier 如何使用 SwiftUI 的 task() 修饰符运行任务-Stewed Noodles 资源

How to run tasks using SwiftUI’s task() modifier 如何使用 SwiftUI 的 task() 修饰符运行任务

SwiftUI provides a task() modifier that starts a new task as soon as a view appears, and automatically cancels the task when the view disappears. This is sort of the equi...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri8个月前
110
How to create and use task local values 如何创建和使用任务本地值-Stewed Noodles 资源

How to create and use task local values 如何创建和使用任务本地值

Swift lets us attach metadata to a task using task-local values, which are small pieces of information that any code inside a task can read.Swift 允许我们使用 task-local ...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri8个月前
110
How to create a task group and add tasks to it 如何创建任务组并向其添加任务-Stewed Noodles 资源

How to create a task group and add tasks to it 如何创建任务组并向其添加任务

Swift’s task groups are collections of tasks that work together to produce a single result. Each task inside the group must return the same kind of data, but if you use enum assoc...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri8个月前
110
Sending data safely across actor boundaries 跨参与者边界安全地发送数据-Stewed Noodles 资源

Sending data safely across actor boundaries 跨参与者边界安全地发送数据

Swift tries to ensure access to shared data is done safely, partly through types such as actors, and partly through a concept of sendability implemented through the ...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri8个月前
0110
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 资源烩之面大会员jiulinxiri8个月前
110
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 资源烩之面大会员jiulinxiri8个月前
110
Introduction to testing Swift concurrency Swift 并发测试简介-Stewed Noodles 资源

Introduction to testing Swift concurrency Swift 并发测试简介

Swift's full range of concurrency features work great with unit tests using both the legacy XCTest framework and the new Swift Testing framework.Swift 的全套并发功能非常适合使用旧...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri8个月前
100
How to test AsyncSequence and AsyncStream 如何测试 AsyncSequence 和 AsyncStream-Stewed Noodles 资源

How to test AsyncSequence and AsyncStream 如何测试 AsyncSequence 和 AsyncStream

Concurrent Swift code often streams values over time rather than returning them all at once, so it's important to be able to write tests to check an AsyncStream, AsyncSeq...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri8个月前
100
How to set a time limit for concurrent tests 如何为并发测试设置时间限制-Stewed Noodles 资源

How to set a time limit for concurrent tests 如何为并发测试设置时间限制

Both Swift Testing and XCTest have simple mechanisms for controlling how long tests should be allowed to run before being considered a failure. This is critically important for con...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri8个月前
100
How to create continuations that can throw errors 如何创建可以抛出错误的continuations-Stewed Noodles 资源

How to create continuations that can throw errors 如何创建可以抛出错误的continuations

Swift provides withCheckedContinuation() and withUnsafeContinuation() to let us create continuations that can’t throw errors, but if the API you’re using ...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri8个月前
100