swift-concurrency-6-2
Swift 6.2のアクセシブルな並行処理——デフォルトはシングルスレッド、@concurrentは明示的なバックグラウンドオフロードに使用し、分離の一貫性はMainActor型に使用する。
Original · translation did not pass checksTarget: Target not categorized. Automatically collected · unverified.
Excerpt from the author’s documentation
Extracted from a fixed version of SKILL.md in its original language. This is the author’s documentation; installation, compatibility and runtime results have not been verified by this site.
Read the original Japanese text
Topics in the source
- Swift 6.2 アクセシブルな並行処理
- 起動条件
- 核心的な問題:暗黙のバックグラウンドオフロード
- コアパターン——分離の一貫性
- コアパターン——グローバル変数と静的変数
- MainActorデフォルト推論パターン
- コアパターン——@concurrent を使ったバックグラウンド処理
- 重要な設計上の決定
コードがデフォルトでシングルスレッドで実行され、並行処理が明示的に導入されるSwift 6.2の並行処理モデルを採用したパターン。パフォーマンスを犠牲にすることなく、よくあるデータ競合エラーを排除する。 Swift 5.x または 6.0/6.1 プロジェクトを Swift 6.2 に移行する場合 データ競合安全性のコンパイラエラーを解決する場合 MainActorベースのアプリアーキテクチャを設計する場合 CPU集約的な処理をバックグラウンドスレッドにオフロードする場合 MainActor分離された型にプロトコル一貫性を実装する場合 Xcode 26で「アクセシブルな並行処理」ビルド設定を有効にする場合 Swift 6.1以前では、非同期関数が暗黙的にバックグラウンドスレッドにオフロードされ、一見安全に見えるコードでもデータ競合エラーを引き起こすことがあった: Swift 6.2ではこの問題が修正された:非同期関数はデフォルトで呼び出し元と同じActorに留まる。 MainActor型が非分離プロトコルに安全に準拠できるようになった: コンパイラはこの一貫性がMainActor上でのみ使用されることを保証する: MainActorを使用してグローバル/静的状態を保護する: Swift 6.2ではMainActorをデフォルトで推論するパターンが導入された——手動の注釈なし: このパターンはオプトインで、アプリ、スクリプト、その他の実行可能ターゲットに推奨される。 真の並列処理が必要な場合、@concurrent を使って明示的にオフロードする: 重要: この例は「アクセシブルな並行処理」ビルド設定——SE-0466 (MainActorデフォルト分離) と SE-0461 (デフォルト非分離非送信) の有効化が必要。これらの設定を有効にすると、extractSticker は呼び出し元のActorに留まり、可変状態へのアクセスが安全になる。これらの設定なしでは、このコードにはデータ競合がある——コンパイラがフラグを立てる。 @concurrent を使用するには: 1. コンテナとなる型に nonisolated をマークする 2. 関数に @concurrent を追加する 3. 関数がまだ非同期でない場合は async を追加する 4. 呼び出し側に await を追加する | 決定 | 理由 | |----------|-----------| | デフォルトシングルスレッド | 最も自然なコードはデータ競合がない。並行処理はオプトイン | | 非同期関数は呼び出し元のActorに留まる | データ競合エラーを引き起こす暗黙のオフロードを排除 | | 分離の一貫性 | MainActor型が安全でない回避策なしにプロトコルに準拠できる | | @co
This is an excerpt. Refer to the complete source and its current requirements.
- Source repository
- affaan-m/ECC
- Source file
- docs/ja-JP/skills/swift-concurrency-6-2/SKILL.md
- Fixed revision
- d2ef2680594f9a17526a6e1a2e18b3d242c5d17b
Requirements
- Only the author’s Skill metadata is included. Read the full instructions to check dependencies, licensing and conditions of use.
A small first task
先阅读原作者说明,再决定是否在自己的 AI 工具中使用。
Instructions for your AI tool
- Claude Desktop: resource-specific guide not available yet
- Claude Code: resource-specific guide not available yet
- Cursor: resource-specific guide not available yet
- Codex: resource-specific guide not available yet
Author documentation is not live verification by this site. Without evidence, we do not mark a resource as compatible, safe or free.
Sources and evidence
This record was collected automatically. Its documentation, suitability and runtime behavior have not been manually verified.
Author: affaan-m/ECC · original repository metadata. Documentation review: Not reviewed. Last source check: 2026-11-09T14:01:49.739Z.
Categories are inferred from names, descriptions and paths. They do not establish compatibility.
License and attribution
MIT. Third-party content and copyright remain with their authors. Refer to the original license and terms.
Original license ↗Synchronization, copying and user-reported success do not mark a resource as runtime-tested.
Limitations and notes
- Collecting metadata does not mean this site has installed, adapted, runtime-tested or security-reviewed the resource.