jiulinxiri-Stewed Noodles 资源-第14页
jiulinxiri的头像-Stewed Noodles 资源
超级管理员河南管理员
一拳之石取其了坚,一勺之水取其净!
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 ...
How to store continuations to be resumed later 如何存储要稍后恢复的 continuations-Stewed Noodles 资源

How to store continuations to be resumed later 如何存储要稍后恢复的 continuations

Many of Apple’s frameworks report back success or failure using multiple different delegate callback methods rather than completion handlers, which means a simple continuation won...
How to convert an AsyncSequence into a Sequence 如何将 AsyncSequence 转换为 Sequence-Stewed Noodles 资源

How to convert an AsyncSequence into a Sequence 如何将 AsyncSequence 转换为 Sequence

Swift does not provide a built-in way of converting an AsyncSequence into a regular Sequence, but often you’ll want to make this conversion yourself so you don’t n...
How to create and run a task 如何创建和运行任务-Stewed Noodles 资源

How to create and run a task 如何创建和运行任务

Swift’s Task struct lets us start running some work immediately, and optionally wait for the result to be returned. And it is optional: sometimes you don’t ca...
Understanding how priority escalation works 了解优先级提升的工作原理-Stewed Noodles 资源

Understanding how priority escalation works 了解优先级提升的工作原理

Every task can be created with a specific priority level, or it can inherit a priority from somewhere else. But in two specific circumstances, Swift will raise the priori...
How to voluntarily suspend a task  如何自愿暂停任务-Stewed Noodles 资源

How to voluntarily suspend a task 如何自愿暂停任务

If you’re executing a long-running task that has few if any suspension points, for example if you’re repeatedly iterating over an intensive loop, you can call Task.yield()&n...
Who decides which actor code runs on? 谁决定在哪个 actor 代码上运行?-Stewed Noodles 资源

Who decides which actor code runs on? 谁决定在哪个 actor 代码上运行?

One common confusion with actors comes in deciding exactly where code runs, because just adding @MainActor and hoping for the best is rarely good enough.与 Actor 的一个常...
What is actor reentrancy and how can it cause problems? 什么是 actor 重入性,它如何导致问题?-Stewed Noodles 资源

What is actor reentrancy and how can it cause problems? 什么是 actor 重入性,它如何导致问题?

Actor-isolated functions are reentrant, which means it's possible for one piece of work to begin before a previous piece of work completes. This opens the possibility of subtle bug...
How to write basic async tests 如何编写基本的异步测试-Stewed Noodles 资源

How to write basic async tests 如何编写基本的异步测试

Both Swift Testing and XCTest allow us to test asynchronous code built with Swift concurrency by marking tests as async. This means we can wait for concurrent code to complete...
How to serialize parameterized tests with Swift Testing 如何使用 Swift Testing 序列化参数化测试-Stewed Noodles 资源

How to serialize parameterized tests with Swift Testing 如何使用 Swift Testing 序列化参数化测试

Swift Testing's parameterized tests allow us to send multiple values into a single test, and they'll be run in parallel for maximum performance. If you don't want this – if you wa...