
Chris Thomasson wrote:
Is this inferior to your proposed scheme?
Maybe... Currently, all of my pointer-ops are 100% lock-free. My reference count adjustments are 100% lock-free for everything except strong competing accesses (e.g., it only *takes a spinlock for strong competing accesses, **and when the count drops to zero). My counter objects can be swapped using normal word-based atomic operations (e.g., XCHG and CAS, no DWCAS required)...
How do you distingush strong competing accesses from noncompeting accesses? You have two pointers, global and local; what levels of thread safety do these offer? Is global the atomic pointer and local the "as safe as an int" equivalent? Or is local to be kept local to a thread? If I have ptr::global<X> px; and I copy px into another global, does this take a spinlock? If I assign to it? Sorry for asking so many questions, but lock-free source code is hard. :-)