Tasks and task groups 第2页
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 资源烩之面大会员jiulinxiri5个月前
40
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...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri5个月前
80
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 资源烩之面大会员jiulinxiri5个月前
70
How to get a Result from a task 如何从任务中获取 Result-Stewed Noodles 资源

How to get a Result from a task 如何从任务中获取 Result

If you want to read the return value from a Task directly, you should read its value using await, or use try await if it has a throwing operation...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri5个月前
60
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 资源烩之面大会员jiulinxiri5个月前
50
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 资源烩之面大会员jiulinxiri5个月前
70
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...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri5个月前
080
What are tasks and task groups? 什么是任务和任务组?-Stewed Noodles 资源

What are tasks and task groups? 什么是任务和任务组?

Using async/await in Swift allows us to write asynchronous code that is easy to read and understand, but by itself it doesn’t enable us to run anything concurrently – even w...
jiulinxiri的头像-Stewed Noodles 资源烩之面大会员jiulinxiri5个月前
60