jiulinxiri-Stewed Noodles 资源-第7页
jiulinxiri的头像-Stewed Noodles 资源
超级管理员河南管理员
一拳之石取其了坚,一勺之水取其净!
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 ...
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...
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...
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...
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 ...
How to make async command-line tools and scripts 如何制作异步命令行工具和脚本-Stewed Noodles 资源

How to make async command-line tools and scripts 如何制作异步命令行工具和脚本

If you’re writing a command-line tool with Swift, you can use async code in two ways: if you're using main.swift you can immediately make and use async functions as norm...
What’s the difference between async let, tasks, and task groups? async let、tasks 和 task groups 之间有什么区别?-Stewed Noodles 资源

What’s the difference between async let, tasks, and task groups? async let、tasks 和 task groups 之间有什么区别?

Swift’s async let, Task, and task groups all solve a similar problem: they allow us to create concurrency in our code so the system is able to run them efficiently. Beyo...
How to discard results in a task group 如何丢弃任务组中的结果-Stewed Noodles 资源

How to discard results in a task group 如何丢弃任务组中的结果

Swift has a special task group type called a discarding task group, which has a very specialized function: tasks that complete are automatically discarded and destroyed, ...
How to handle different result types in a task group 如何处理任务组中的不同结果类型-Stewed Noodles 资源

How to handle different result types in a task group 如何处理任务组中的不同结果类型

Each task in a Swift task group must return the same type of data as all the other tasks in the group, which is often problematic – what if you need one task group to handle ...
How to cancel a task group 如何取消任务组-Stewed Noodles 资源

How to cancel a task group 如何取消任务组

Swift’s task groups can be cancelled in one of three ways: if the parent task of the task group is cancelled, if you explicitly call cancelAll() on the group, or if one of your ...