Expand description
A tree of per-thread slots that are folded lazily into their father.
Writers only ever touch the node they own, so they never share a cache line; the aggregate is rebuilt on demand, when someone reads the root.
§Contract
merge and identity must form a commutative monoid over T:
- identity:
merge(&mut x, &identity)leavesxunchanged. - associative and commutative: sons are folded in an order that depends on thread scheduling, so any order must give the same answer.
A node’s data is the delta not yet folded into its father, not a local
copy of the aggregate. A fresh son starts at identity, and a node is reset
to identity as soon as its data has been folded upward.
Structs§
- Mergex
- Handle to a node in the tree. Cloning (or moving one into a thread) shares the node, it does not copy it.
Type Aliases§
- MergeFn
- Merge function: folds a son’s data into its father’s data. Must be associative and commutative; see the crate docs.