Make SYST.has_wrapped() take &self
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 重构
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- rust
- 领域
- embedded-iot
调研方向
首先定位 SYST::has_wrapped() 及其使用的 csr.read() 操作,然后检查其调用方对可变访问和线程安全性的假设。评估将 receiver 更改为 &self 或将方法设为 unsafe 是否保留文档中说明的副作用,并添加或更新用于展示预期行为的测试。
由索引模型根据 Issue 内容生成。
描述
While I understand the intention in making SYST.has_wrapped() take &mut self because of the side effect, I believe the trouble this causes are bigger than any pain it aims to save.
For example, implementing a shared clock, because of &mut requirement one now has to use a mutex before accessing has_wrapped(). The locking operation infers a non-negligible and unwelcome CPU load especially in a time-sensitive and oft-called method.
The register operation csr.read() backing has_wrapped() being inherently atomic in it's operation guarantees that the side effect will always be observed by a single thread. Also, this side-effect is mostly non-deterministic, i.e. one does not "expect" a particular has_wrapped() return value in any situation. It's something that has to be unconditionally checked by every thread and will thus not lead to a race condition.
In a sense, this should be similar to reading an event from a lock-free queue. &mut is more about enforcing exclusivity than mutability. In the case of has_wrapped the exclusivity is unwarranted.
Thus I contend that has_wrapped() should be changed to take &self. It could also be made unsafe to make one think about how it works and retain the original intention behind the current &mut.
- 主要语言
- Rust
- 星标
- 1k
- 派生
- 201
- 平均合并
- 5 小时 8 分钟
- 30 天内合并 PR
- 3
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
rust-embedded/cortex-m 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 69/100
rust-embedded/cortex-m#702 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 62/100
rust-embedded/cortex-m#651 · 5 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
rust-embedded/cortex-m#637 ·
-
enhancement
难度 2/5 1-3 小时 新手友好度 76/100
rust-embedded/cortex-m#511 · 2 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 55/100
rust-embedded/cortex-m#700 · 1 条评论 ·
查看 rust-embedded/cortex-m 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 67/100
rust-bitcoin/rust-bitcoin#7089 · 1 条评论 · 1 个 reaction ·
维护者通常 2 天内回复
-
area/tools bug session-analysis
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
[Bug]: Python OpenTelemetrySectionConfig has no file_sinks可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
NVIDIA/NeMo-Relay#1514 ·
维护者通常 1 天内回复
-
prompting proposal tool triaged
难度 2/5 1-3 小时 新手友好度 78/100
can1357/oh-my-pi#17041 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 84/100
nix-community/fenix#262 ·