In the absence of multithreading, the implementation of copy-on-write for
shared_ptr(either from boost or tr1) using unique()is simple. What changes need to be made with multithreading? The reference count is atomic, so I assume that I can create, copy-build, read and destroy instances shared_ptrwithout additional problems. How about updating them in general, and especially when implementing copy-on-write? Do you need locks? Or use boost::atomic_store
(why is this not documented)? Or wait for the fully atomic version
shared_ptr(not an option)?
Edit:
sfossen, thanks for your reply. Therefore, I conclude that if I change the object with a pointer to the object only after disconnecting it through COW, so that it only owns the current thread, it does not require blocking and the COW implementation looks the same as single-threaded when using shared_ptr with atomic reflexes.
wilbur_m
source
share