Join the discussion
Write your take first — we'll ask for email only when you're ready to publish.
- Hacker News
- Great, well-written read.by Bnjoroge
- Well written, good content, doesn't try to sell random junk, +10 would read again :)by windenntw
- This sort of approach relies on it being safe to read torn updates, which technically is UB in C++
As someone else mentions, it's also difficult for anybody to free memory (which for many purposes is actually fine)
by nly - Naive question, since this isn't my area of expertise, but Rust has RwLock: Why wouldn't one simply use RwLock to allow many readers and a single writer?
How does this approach outperform RwLock (for arbitrary interpretations of outperform) and how does RwLock outperform this approach (ditto)?
- This code seems broken, though. The big challenge with these kinds of lock-free parallel algorithms is always how to deal with lifetimes and prevent use-after-frees (unless you never want to free anything from this tree, which seems a bit unlikely).
The fundamental problem is that nothing prevents a reader from dereferencing a node the writer has free()'d. Fixing this requires either adding RCU or Hazard pointers.