eyt*
July 3, 2004

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

In the July and August issues 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.


Posted 18 years, 2 months ago on July 3, 2004
The trackback url for this post is https://www.eyt.ca/blog/bblog/trackback.php/28/

Comments have now been turned off for this post. If you want to share something, please e-mail me.

Navigation

Recent Posts

eyt*