eyt*
Jul 03, 2004

"C++ and the Perils of Double-Check Locking..."

In the July and August issue of Dr. Dobbs, Scott Meyers and Andrei Alexandrescu have written a piece entitled, C++ and the Perils of Double-Check Locking.

I previously talked about Double-Check Locking here, and I find that their article really adds little to this, except that to avoid the global lock, they recommend more user caching of the instance variable to avoid the expense of acquiring the lock, avoid the lazy initialization, use a different pattern such as the Monostate pattern (which Scott quickly points out that his Effective C++ mentions this, and also highlights a problem with the Monostate pattern that is solved with the Singleton pattern), and the use of thread-specific singletons.

The thing that bothers me about this article is that it seems that Scott and Andrei have discovered this issue, as they give no credit to the authors of The "Double-Check Locking is Broken" Declaration. Aside from this minor detail, the article is an interesting read, especially in its treatment of the volatile keyword.

In more exciting news, Scott is talking in Stuttgart, Germany about the upcoming major changes in Effective C++ (the Third Edition), and is also talking about his work on the keyhole problem in his OOPSLA's tutorial, Better Software--No Matter What. Looking forward to hearing more about this.

Filed In

Navigation

eyt*