Swift Concurrency by Example 第2页
How to make parts of an actor nonisolated 如何使 actor 的各个部分非隔离-Stewed Noodles 资源

How to make parts of an actor nonisolated 如何使 actor 的各个部分非隔离

All methods and mutable properties inside an actor are isolated to that actor by default, which means they cannot be accessed directly from code that’s external to the actor. Acce...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri8个月前
200
How to cancel a Task 如何取消任务-Stewed Noodles 资源

How to cancel a Task 如何取消任务

Swift’s tasks use cooperative cancellation, which means that although we can tell a task to stop work, the task itself is free to completely ignore that instruction and carry...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri8个月前
190
Swift Concurrency by Example-Stewed Noodles 资源

Swift Concurrency by Example

Async/await Sequences and streams Tasks and task groups Actors Testing Solutions
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri8个月前
180
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 的一个常...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri8个月前
170
What calls the first async function? 什么调用第一个异步函数?-Stewed Noodles 资源

What calls the first async function? 什么调用第一个异步函数?

You can only call async functions from other async functions, because they might need to suspend themselves and everything that is waiting for them. This leads to a bit of a chicke...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri8个月前
0170
Understanding actor initialization 了解 actor 初始化-Stewed Noodles 资源

Understanding actor initialization 了解 actor 初始化

Swift's actors run on their own executor most of the time, so they manage how and where their work is done. However, during the actor's initialization its executor isn't ready to t...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri8个月前
170
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...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri8个月前
170
How to use continuations to convert completion handlers into async functions 如何使用 continuations 将完成处理程序转换为异步函数-Stewed Noodles 资源

How to use continuations to convert completion handlers into async functions 如何使用 continuations 将完成处理程序转换为异步函数

Older Swift code uses completion handlers for notifying us when some work has completed, and sooner or later you’re going to have to use it from an async function –&nbs...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri8个月前
160
How to call async throwing functions 如何调用异步 throwing 函数-Stewed Noodles 资源

How to call async throwing functions 如何调用异步 throwing 函数

Just like their synchronous counterparts, Swift’s async functions can be throwing or non-throwing depending on how you want them to behave. However, there is a twist: although we ...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri8个月前
0160
What is an actor and why does Swift have them? 什么是 actor,为什么 Swift 有它们?-Stewed Noodles 资源

What is an actor and why does Swift have them? 什么是 actor,为什么 Swift 有它们?

Swift’s actors are conceptually like classes that are safe to use in concurrent environments. This safety is made possible because Swift automatically ensures no two pieces of cod...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri8个月前
160