-rw-r--r-- | noncore/multimedia/opieplayer2/singleton.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/singleton.h b/noncore/multimedia/opieplayer2/singleton.h index 83e228f..825344e 100644 --- a/noncore/multimedia/opieplayer2/singleton.h +++ b/noncore/multimedia/opieplayer2/singleton.h @@ -22,2 +22,4 @@ +#include "threadutil.h" + template <class Product> @@ -44,4 +46,7 @@ public: { + if ( !s_self ) { + ThreadUtil::AutoLock lock( s_guard ); if ( !s_self ) s_self = Creator<T>::create(); + } return *s_self; @@ -60,2 +65,3 @@ private: static T *s_self; + static ThreadUtil::Mutex s_guard; }; @@ -65,2 +71,5 @@ T *Singleton<T, Creator>::s_self = 0; +template <class T, template <class> class Creator> +ThreadUtil::Mutex Singleton<T, Creator>::s_guard; + #endif // SINGLETON_H |