Swift Concurrency by Example共61篇
How to make function parameters isolated 如何隔离函数参数-Stewed Noodles 资源

How to make function parameters isolated 如何隔离函数参数

Any properties and methods that belong to an actor are isolated to that actor, but you can make external functions isolated to an actor if you want. This allows the funct...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri5个月前
270
How to create and use an actor in Swift 如何在 Swift 中创建和使用 actor-Stewed Noodles 资源

How to create and use an actor in Swift 如何在 Swift 中创建和使用 actor

Creating and using an actor in Swift takes two steps: create the type using actor rather than class or struct, then use await when accessing its ...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri5个月前
170
How to use @MainActor to run code on the main queue 如何使用 @MainActor 在主队列上运行代码-Stewed Noodles 资源

How to use @MainActor to run code on the main queue 如何使用 @MainActor 在主队列上运行代码

@MainActor is a global actor that uses the main queue for executing its work. In practice, this means methods or types marked with @MainActor can (for the most part)...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri5个月前
160
What is an asynchronous function?什么是异步函数?-Stewed Noodles 资源

What is an asynchronous function?什么是异步函数?

Although Swift functions are synchronous by default, we can make them asynchronous by adding one keyword: async. Inside asynchronous functions, we can call other asy...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri5个月前
150
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 资源烩之面大会员jiulinxiri5个月前
0140
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 资源烩之面大会员jiulinxiri5个月前
140
What is a synchronous function? 什么是同步函数?-Stewed Noodles 资源

What is a synchronous function? 什么是同步函数?

By default, all Swift functions are synchronous, but what does that mean? A synchronous function is one that executes all its work in a simple, straight line on a single threa...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri5个月前
0130
How to loop over an AsyncSequence using for await 如何使用 for await 遍历 AsyncSequence-Stewed Noodles 资源

How to loop over an AsyncSequence using for await 如何使用 for await 遍历 AsyncSequence

You can loop over an AsyncSequence using Swift’s regular loop types, for, while, and repeat, but whenever you read a value from the async sequence you mus...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri5个月前
120
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 资源烩之面大会员jiulinxiri5个月前
110
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 资源烩之面大会员jiulinxiri5个月前
110