- Timestamp:
- 11/10/09 18:25:49 (4 years ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2
- Children:
- b4ab033
- Parents:
- 6672c56
- Location:
- include/settings
- Files:
-
- 2 edited
-
Settings.h (modified) (12 diffs)
-
settings_ini.hpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
include/settings/Settings.h
rd5356c1 r773ad32 24 24 #include <string> 25 25 #include <map> 26 #include <Mutex.h> 26 #include <boost/thread/thread.hpp> 27 #include <boost/thread/locks.hpp> 28 #include <strEx.h> 27 29 #define BUFF_LEN 4096 28 30 … … 615 617 SettingsInterface* instance_; 616 618 instance_list instances_; 617 MutexHandlermutexHandler_;619 boost::timed_mutex mutexHandler_; 618 620 /* 619 621 struct key_description : public SettingsCore::key_description { … … 714 716 715 717 SettingsInterface* get() { 716 MutexLock mutex(mutexHandler_);717 if (!mutex. hasMutex())718 boost::unique_lock<boost::timed_mutex> mutex(mutexHandler_, boost::get_system_time() + boost::posix_time::seconds(5)); 719 if (!mutex.owns_lock()) 718 720 throw SettingsException(_T("Failed to get mutext, cant get settings instance")); 719 721 if (instance_ == NULL) … … 724 726 } 725 727 SettingsInterface* get(SettingsCore::settings_type type) { 726 MutexLock mutex(mutexHandler_);727 if (!mutex. hasMutex())728 boost::unique_lock<boost::timed_mutex> mutex(mutexHandler_, boost::get_system_time() + boost::posix_time::seconds(5)); 729 if (!mutex.owns_lock()) 728 730 throw SettingsException(_T("Failed to get mutext, cant get settings instance")); 729 731 return instance_unsafe(type); … … 783 785 get_logger()->debug(__FILEW__, __LINE__, _T("Starting to migrate...")); 784 786 #endif 785 MutexLock mutex(mutexHandler_);786 if (!mutex. hasMutex())787 boost::unique_lock<boost::timed_mutex> mutex(mutexHandler_, boost::get_system_time() + boost::posix_time::seconds(5)); 788 if (!mutex.owns_lock()) 787 789 throw SettingsException(_T("migrate_type: Failed to get mutext, cant get settings instance")); 788 790 SettingsInterface* iFrom = instance_unsafe(from); … … 803 805 } 804 806 SettingsCore::settings_type get_settings_type() { 805 MutexLock mutex(mutexHandler_);806 if (!mutex. hasMutex())807 boost::unique_lock<boost::timed_mutex> mutex(mutexHandler_, boost::get_system_time() + boost::posix_time::seconds(5)); 808 if (!mutex.owns_lock()) 807 809 throw SettingsException(_T("Failed to get mutext, cant get load settings")); 808 810 if (instance_ == NULL) … … 823 825 } 824 826 bool has_type(SettingsCore::settings_type type) { 825 MutexLock mutex(mutexHandler_);826 if (!mutex. hasMutex())827 boost::unique_lock<boost::timed_mutex> mutex(mutexHandler_, boost::get_system_time() + boost::posix_time::seconds(5)); 828 if (!mutex.owns_lock()) 827 829 throw SettingsException(_T("has_type Failed to get mutext, cant get access settings")); 828 830 instance_list::const_iterator cit = instances_.find(type); … … 830 832 } 831 833 void set_type(SettingsCore::settings_type type) { 832 MutexLock mutex(mutexHandler_);833 if (!mutex. hasMutex())834 boost::unique_lock<boost::timed_mutex> mutex(mutexHandler_, boost::get_system_time() + boost::posix_time::seconds(5)); 835 if (!mutex.owns_lock()) 834 836 throw SettingsException(_T("set_type Failed to get mutext, cant get access settings")); 835 837 instance_list::const_iterator cit = instances_.find(type); … … 839 841 } 840 842 void add_type_impl(SettingsCore::settings_type type, SettingsInterface* impl) { 841 MutexLock mutex(mutexHandler_);842 if (!mutex. hasMutex())843 boost::unique_lock<boost::timed_mutex> mutex(mutexHandler_, boost::get_system_time() + boost::posix_time::seconds(5)); 844 if (!mutex.owns_lock()) 843 845 throw SettingsException(_T("add_type_impl Failed to get mutext, cant get access settings")); 844 846 instance_list::iterator it = instances_.find(type); … … 1150 1152 1151 1153 void add_instance(SettingsInterface *instance) { 1152 MutexLock mutex(mutexHandler_);1153 if (!mutex. hasMutex())1154 boost::unique_lock<boost::timed_mutex> mutex(mutexHandler_, boost::get_system_time() + boost::posix_time::seconds(5)); 1155 if (!mutex.owns_lock()) 1154 1156 throw SettingsException(_T("load_all_instance Failed to get mutext, cant get access settings")); 1155 1157 instance_list::iterator it = instances_.find(instance->get_type()); … … 1172 1174 private: 1173 1175 void destroy_all_instances() { 1174 MutexLock mutex(mutexHandler_);1175 if (!mutex. hasMutex())1176 boost::unique_lock<boost::timed_mutex> mutex(mutexHandler_, boost::get_system_time() + boost::posix_time::seconds(5)); 1177 if (!mutex.owns_lock()) 1176 1178 throw SettingsException(_T("destroy_all_instances Failed to get mutext, cant get access settings")); 1177 1179 instance_ = NULL; … … 1186 1188 } 1187 1189 SettingsInterface *get_default_settings_instance_unsafe() { 1188 MutexLock mutex(mutexHandler_);1189 if (!mutex. hasMutex())1190 boost::unique_lock<boost::timed_mutex> mutex(mutexHandler_, boost::get_system_time() + boost::posix_time::seconds(5)); 1191 if (!mutex.owns_lock()) 1190 1192 throw SettingsException(_T("destroy_all_instances Failed to get mutext, cant get access settings")); 1191 1193 instance_ = NULL; -
include/settings/settings_ini.hpp
rf0eb62d r773ad32 5 5 #include <settings/Settings.h> 6 6 #include <simpleini/SimpleIni.h> 7 #include <error.hpp> 7 8 8 9 namespace Settings {
Note: See TracChangeset
for help on using the changeset viewer.








