The 'Double-check Locking Pattern' is used for getting instances of a singleton without always having to go through a guard.
First you check the pointer to the singleton object, then enter the guard's scope, then check the pointer again. Once the pointer is set, you no longer use the guard.
Reference: Modern C++ Design: Generic Programming and Design Patterns Applied by Andrei Alexandrescu. Addison-Wesley, 2001, pp. 146-147.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment