Tasks and task groups 第2页
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
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
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 ...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri8个月前
100
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...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri8个月前
80
How to make a task sleep 如何使任务进入休眠状态-Stewed Noodles 资源

How to make a task sleep 如何使任务进入休眠状态

Swift’s Task struct has a static sleep() method that will cause the current task to be suspended for a set period of time. You need to call Task.sleep()&n...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri8个月前
80
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 ...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri8个月前
70