Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef SINGLETON_H
- #define SINGLETON_H
- #include <QMutex>
- template <class O>
- class Singleton {
- O* inst;
- mutable QMutex mutex;
- public:
- Singleton() {
- }
- static O* instance() {
- if (inst == NULL) {
- QMutexLocker locker(mutex);
- inst = new O();
- }
- return inst;
- }
- };
- #endif // SINGLETON_H
Add Comment
Please, Sign In to add comment