← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 1537.a.4.a.1 · 生成模型:GPT-6

线程本地仍需独占借用

理解等级:高级

单线程仍能在等待或回调重入时产生重叠借用。UnsafeCell 允许通过共享引用内部修改,独占可变引用的约束依旧适用。应将可变借用限制在可审计的同步区域,阻止重入及引用逃逸。参见 Rust UnsafeCell 契约。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • Chapter 7. Customizing Tokio 线程本地数据仍需借用约束 · 查看原书依据

      If we think about our system, we have a single thread processing async tasks that will not transfer to other threads. We must remember that although this single thread can juggle multiple async tasks at the same time through polling, it can actively process only one async task at a time. Therefore, we can assume that while one of our async tasks is accessing the

    参考来源

    - 位置:《Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)》第07章《Chapter 7. Customizing Tokio》,线程本地数据仍需借用约束(来源项目 book-source,extracted/Async Rust Unleashing the Power of Fearless Concurrency (Maxwell Flitton, Caroline Morton)/_epub-src/OEBPS/ch07.html#id50) - 结论依据:原书强调不能持本地 UnsafeCell 派生引用跨 await。 - 原始内容:If we think about our system, we have a single thread processing async tasks that will not transfer to other threads. We must remember that although this single thread can juggle multiple async tasks at the same time through polling, it can actively process only one async task at a time. Therefore, we can assume that while one of our async tasks is accessing the