Subj : Re: posix and lock-free algorithms To : comp.programming.threads From : Alexander Terekhov Date : Thu Aug 11 2005 06:51 pm John Doug Reynolds wrote: [...] > I'm uncertain whether you are objecting to the apparently local nature > of the Lock in my original transcription, or whether you are pointing > to a more fundamental problem. If so, could you explain your > assertions more fully? To begin with, even if compiler won't optimize-out your per-thread locks (which is perfectly legal), compiler and/or hardware can transform your : Singleton* tmp = new Singleton; : local.lock(); local.unlock(); // just a memory barrier : pInstance = tmp; to (in effect): < pseudo-code; assume everything is throw()-nothing > local.lock(); pInstance = Singleton::operator new(); ::new(pInstance) Singleton(); local.unlock(); regards, alexander. .