ev-mold-atomic-flag-resolve-003¶
| 字段 | 值 |
|---|---|
| 项目 | rui314/mold |
| 固定 commit | 27162691b71a |
| 路径 | src/passes.cc |
| 行段 | L318-L322 |
| 特性 | std::atomic |
| 许可证 | MIT |
| 代码来源 | 项目源码 |
| 级别 | manual |
| 审核 | zyuhao7 @ 2026-11-03 |
| 测试代码 | 否 |
| 发现方式 | manual |
用法¶
用 std::atomic_bool 在并行符号解析中记录需要重试的状态
为什么典型¶
符号解析在 TBB 并行循环中执行,flag 由多个工作线程观察;atomic_bool 用最轻量的方式共享一个“是否重做”的信号。
摘录¶
// Symbols with hidden visibility need to be resolved within the
// output file. If a hidden symbol was resolved to a DSO, we'll redo
// symbol resolution from scratch with the flag to skip that symbol
// next time. This should be rare.
std::atomic_bool flag = false;
备注¶
生产代码;std::atomic_bool 是 std::atomic