Double Checked Locking

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Dec 17 15:10:19 PST 2011


On 12/17/11 5:03 PM, Jonathan M Davis wrote:
> Well, you learn something new every day I guess. I'd never even heard of
> double-checked locking before this. I came up with it on my own in an attempt
> to reduce how much the mutex was used. Is the problem with it that the write
> isn't actually atomic? Wikipedia makes it sound like the problem might be that
> the object might be partially initialized but not fully initialized, which I
> wouldn't have thought possible, since I would have thought that the object
> would be fully initialized and _then_ the reference would be assigned to it.
> And it's my understanding that a pointer assignment like that would be atomic.
> Or is there more going on than that, making it so that the assignment itself
> really isn't atomic?

There so much going on about double-checked locking, it's not even 
funny. Atomic assignments have the least to do with it. Check this out: 
http://goo.gl/f0VQG


Andrei


More information about the Digitalmars-d mailing list