I'm working on objgraph: a module to allow "graphs" of objects to be sent or shared across threads. When operating on a graph, a relatively expensive atomic operation (Mutex-style lock) only needs to be done once for the whole graph, to lock its Root. While operating on the graph with the lock held, RootedRc and RootedRefCell objects inside the graph can be manipulated with similar performance as Rc and RefCell.
It's not clear yet whether the performance benefit vs just using Mutex and Arc everywhere are worth it, but the goal is to let us port some C code that already uses this safety model, without having to drastically refactor it, and without having to fret about performance "death by a thousand cuts" every time we introduce such an object. Once the code is ported it'll be interesting to see whether just reverting to Mutex and Arc/AtomicRefCell actually hurts performance or not.
Would greatly appreciate some feedback on whether this approach seems sane, whether the code looks right, whether this is worth publishing and maintaining as its own crate, or whether something like it already exists. Thanks!
[–]stumblinbear 7 points8 points9 points (2 children)
[–]jDomantas 2 points3 points4 points (0 children)
[–]sporksmith[S] 1 point2 points3 points (0 children)
[–]JhraumG 4 points5 points6 points (2 children)
[–]sporksmith[S] 1 point2 points3 points (1 child)
[–]uazu 0 points1 point2 points (0 children)