FREE Subscription to Dr. Dobb’s Digest: Same Great Content, New Digital Edition
Site Archive (Complete)
C++ Blog: Thread-safe Singletons
C++
void main(void)

Calls, Returns and In-Between.

by Kevin Carlson
SELECTIVE IGNORANCE

Finding the Signal in the Noise

by Andrew Koenig
May 08, 2007

Thread-safe Singletons

Vladimir Kliatchko found recently that there wasn't a universal solution for the thread-safe initialization and destruction of Singletons. A C++ file-scope variable for initialization wouldn't work, and the pattern he turned to, the Meyers Singleton (in which the Singleton is intialized upon first use) didn't really solve the thread safety issue. Here's what Vladimir came up with as a solution.

Posted by Kevin Carlson at 01:26 PM  Permalink




 
INFO-LINK