知识卡片
不重叠切片并行写
chunks_mut 把一块可变缓冲区划成互不重叠的子切片。每个线程持有一块的独占访问权,即可同时填充不同区域。按整行分块时切片大小须是宽度的倍数,末块使用实际长度推算行数。这个划分在创建子切片时表达了共享结构的安全条件。
关联阅读:[[行主序渲染写入切片]]。
结构图:
flowchart TD
A[整图缓冲区] --> B[按整行切成可变带区]
B --> C[线程渲染带区一]
B --> D[线程渲染带区二及其余带区]
C --> E[等全部线程结束]
D --> E
E --> F[只读借用整图进行编码]
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- A Tour of Rust 让线程在作用域内独占各自的带区 · 查看原书依据
The buffer’s chunks_mut method returns an iterator producing mutable, nonoverlapping slices of the buffer, each of which encloses rows_per_band * bounds.0 pixels—in other
参考来源
- 位置:《Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)》第01章《A Tour of Rust》|让线程在作用域内独占各自的带区,来源项目 `book-source`,`extracted/Programming Rust Fast, Safe Systems Development, 3rd ed. (First Early Release)/_epub-src/OEBPS/ch01.xhtml#a-concurrent-mandelbrot-program`
- 结论依据:原文点明 chunks_mut 的非重叠结果及最后一带可能更短。
- 原始内容:The buffer’s chunks_mut method returns an iterator producing mutable, nonoverlapping slices of the buffer, each of which encloses rows_per_band * bounds.0 pixels—in other