Guest User

Untitled

a guest
Nov 23rd, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. #ifndef SINGLETON_H
  2. #define SINGLETON_H
  3.  
  4. #include <QMutex>
  5.  
  6. template <class O>
  7. class Singleton {
  8. O* inst;
  9. mutable QMutex mutex;
  10.  
  11. public:
  12. Singleton() {
  13. }
  14.  
  15. static O* instance() {
  16. if (inst == NULL) {
  17. QMutexLocker locker(mutex);
  18.  
  19. inst = new O();
  20. }
  21.  
  22. return inst;
  23. }
  24. };
  25.  
  26. #endif // SINGLETON_H
Add Comment
Please, Sign In to add comment