4 ms·
Much like in C, you could use several other schemes such as a Mutex (or RwLock). There are crates which implement more complicated memory management primitives
by cyphar 7y ago
Much like in C, you could use several other schemes such as a Mutex (or RwLock). There are crates which implement more complicated memory management primitives -- the most obvious example being crossbeam[1].
Crossbeam even has an implementation of an epoch-based memory manager[2] which (in very loose terms) amortises the cost of reference counting each object by tracking the epochs of each thread and freeing objects once all threads have moved past the "death time" of an object.
[1]: https://docs.rs/crossbeam/ https://docs.rs/crossbeam/
[2]: https://docs.rs/crossbeam/0.7.3/crossbeam/epoch/index.html https://docs.rs/crossbeam/0.7.3/crossbeam/epoch/index.html
- _bxg1 7y agoNormal mutexes in Rust still have to be paired with a reference-counting structure. Those are separate mechanisms. I don't know anything about the epoch-based manager, but it does sound interesting.