Skip to content

refactor: 改进并发安全与代码质量#1726

Open
kasc0206 wants to merge 2 commits into
apple:mainfrom
kasc0206:refactor/concurrency-and-code-quality
Open

refactor: 改进并发安全与代码质量#1726
kasc0206 wants to merge 2 commits into
apple:mainfrom
kasc0206:refactor/concurrency-and-code-quality

Conversation

@kasc0206

@kasc0206 kasc0206 commented Jun 14, 2026

Copy link
Copy Markdown

修改内容 / Changes

根据代码审查建议(#1727),按优先级实施了以下改进:
Based on the code review recommendations (#1727), the following improvements were implemented by priority:

高优先级:改善 Swift 6 并发安全性 / High Priority: Improve Swift 6 Concurrency Safety

  • Application.swift: 将 bootstrapLoggernonisolated(unsafe) var 改为 Mutex<Logger?> 保护的计算属性,消除 unsafe 并发标记
    Changed bootstrapLogger from nonisolated(unsafe) var to a Mutex<Logger?>-protected computed property, eliminating the unsafe concurrency annotation

低优先级:代码质量改进 / Low Priority: Code Quality Improvements

  • APIServer+Start.swift: 将硬编码的地址和端口号提取到 NetworkConfig 枚举中,提高可配置性
    Extracted hardcoded addresses and port numbers into a NetworkConfig enum for better configurability
  • ContainerRun.swift: 将 cidfile 创建从 createFile + errno 的 C 风格错误处理改为 data.write(to:) 的 Swift throw 式 API
    Replaced C-style error handling (createFile + errno) with Swift throwing API (data.write(to:)) for cidfile creation

验证 / Verification

  • ✅ 构建通过 / Build passes (swift build)

相关 Issue / Related Issue

Closes #1727

kylin added 2 commits June 15, 2026 06:40
- 自动修复:行尾空格、多余空行、blockquote/列表/代码块周围空行
- 为无语言的围栏代码块添加语言标识(bash/text/json)
- 将粗体标题(**Usage** 等)转换为 Markdown 标题(####)
- 对齐表格列格式
- 转换 atx_closed 标题样式
- 创建 .markdownlint.jsonc 配置关闭不适用的规则(行长度、内联 HTML)
- 将 bootstrapLogger 从 nonisolated(unsafe) var 改为 Mutex<Logger?> 保护的计算属性
- 将 APIServer 硬编码端口/地址提取到 NetworkConfig 枚举
- 修复 ContainerRun 中 cidfile 使用 errno C 风格错误处理的问题,改用 throw 式 API
- AWS: 改善 Swift 6 并发安全性
- AWS: 提高可配置性和可测试性
- AWS: 统一错误处理风格
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

代码审查:改进并发安全与代码质量 / Code Review: Improve Concurrency Safety & Code Quality

2 participants