Skip to content

Comment on Too dangerous for C++

Comments

Apparently, this is enough of an issue that C++20 added a partial template specialization to std::atomic<std::shared_ptr>. My advice, though, would be "don't do that!". Instead, keep your shared pointer in a single thread, and send copies to other threads as needed.

This is to support an atomic lock-free shared_ptr. You can then use this as a building block for building lock-free data structures.

Interesting, I was lacking this context. Could you provide me with more information about this? I only saw atomic_shared_ptr come up in discussions about bugs up to now.

https://www.youtube.com/watch?v=gTpubZ8N0no

The target of this optimization is low-latency code. Rendezvous will not work for that.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.