Dear all
While doing the refactoring of this function, the race poped out …. ;-)
if (!x->ref.deref())
delete x;
Now what happens thread T1 has finish checking the above conditional and is then pre empted … T2 runs the the same conditional and deletes x. Thread T1 resumes and deletes x …
As we are using thread safe functions to swap ( if I am right ) the pointers, we should consider all races
Adding multi-threading at some later point in the code is very hard …
—- cheers atul
