Changeset 163eec for src/CodePatterns/Singleton_impl.hpp
- Timestamp:
- Jul 30, 2015, 8:47:36 PM (10 years ago)
- Children:
- 1b5188
- Parents:
- 73ab25
- git-author:
- Frederik Heber <heber@…> (06/01/15 08:23:04)
- git-committer:
- Frederik Heber <heber@…> (07/30/15 20:47:36)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodePatterns/Singleton_impl.hpp
r73ab25 r163eec 38 38 39 39 template <class T,bool _may_create> 40 const T& Singleton<T,_may_create>::getConstInstance(){ 41 // boost supports RAII-Style locking, so we don't need to unlock 42 boost::recursive_mutex::scoped_lock guard(instanceLock); 43 if(!theInstance.get()) { 44 theInstance.reset(creator::make()); 45 } 46 return *theInstance; 47 } 48 49 template <class T,bool _may_create> 40 50 T* Singleton<T,_may_create>::getPointer(){ 51 // boost supports RAII-Style locking, so we don't need to unlock 52 boost::recursive_mutex::scoped_lock guard(instanceLock); 53 if(!theInstance.get()) { 54 theInstance.reset(creator::make()); 55 } 56 return theInstance.get(); 57 58 } 59 60 template <class T,bool _may_create> 61 const T* Singleton<T,_may_create>::getConstPointer(){ 41 62 // boost supports RAII-Style locking, so we don't need to unlock 42 63 boost::recursive_mutex::scoped_lock guard(instanceLock); … … 98 119 #define CONSTRUCT_SINGLETON(name) \ 99 120 template name& Singleton< name , name::may_create >::getInstance(); \ 121 template const name& Singleton< name , name::may_create >::getConstInstance(); \ 100 122 template name* Singleton< name , name::may_create >::getPointer(); \ 123 template const name* Singleton< name , name::may_create >::getConstPointer(); \ 101 124 template void Singleton< name , name::may_create >::purgeInstance(); \ 102 125 template name& Singleton< name , name::may_create >::resetInstance(); \
Note:
See TracChangeset
for help on using the changeset viewer.