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
|