计划执行与检查节点
executing-plans
按既定实施计划完成工作,保持过程检查和反馈。
swift-concurrency【效率与协作】Implement async/await, Actors, and structured concurrency in Swift. Use when implementing Swift async/await, Actors, or structured concurrency in iOS/macOS.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
async and call with await.async let: Use async let for parallel execution when multiple tasks independent.withTaskGroup or withThrowingTaskGroup for spawning dynamic number of tasks.throws. Always handle CancellationError.See implementation examples for parallel fetch with async let and Task Groups.
actor for shared mutable state to avoid data races.@MainActor: Annotate UI classes (Views, ViewModels) with @MainActor for main thread execution. Use MainActor.run { ... } for inline UI updates in async blocks.@GlobalActor for specific thread-bound resources.nonisolated for methods that don't access actor state to avoid unnecessary hops.See implementation examples for Actor-based state isolation and nonisolated methods.
Task { ... }.Task.isCancelled in long loops. Use try Task.checkCancellation() for throwing functions.Task.detached unless you explicitly want to break context inheritance.MainActor.