Subject: Re: [boost] [smart ptr] Any interest in copy-on-write pointer for C++11?
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2013-02-08 12:20:49
On 08/02/13 17:50, Ralph Tandetzky wrote:
> It is as thread-safe as necessary. The reference counter is atomic. It's
> all well documented on github
> <https://github.com/ralphtandetzky/cow_ptr>. You can find all the
> thread-safety guarantees there. Thread-safety is documented at the
> bottom of the long comment preceeding the cow_ptr class.
You should have just used std/boost::shared_ptr and added your COW logic
Your code reinvents the wheel, is quite inefficient (be it in terms of
memory layout, construction or assignment), and I'm not even sure this
is really thread-safe. Lockfree programming is tricky.
If I remember right, boost::shared_ptr required to make some copy
operations atomic as well, which requires a spinlock or 128-bit CAS.
Surely this also applies here.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk