Subj : Re: A question about atomic_ptr To : comp.programming.threads From : Chris Thomasson Date : Fri Apr 15 2005 07:23 pm >>> The point is that you no longer need tricks in the copy constructor. >>> The original race is only a problem when the count is 1 so that you >>> can have the >>> assignment destroy the count and then the copy constructor attempt to >>> increment it. >> >> No. > > Yes, it's broken. The race can occur even if count > 1. Lets say the count is 3, the "increment thread" could be preempted and the three threads that own references could be allowed to run, drop to zero and destroy the count. Then the poor increment thread runs again and wrecks everything! :O > A non-tricky copy constructor cannot be made > race-resistant, no matter how I fiddle with the assignment. Its thread can > always be preempted after it loads the pointer for just enough time for > some > other thread to destroy the count. Yup. :) .