diff options
author | gregorycu <gregory.currie@gmail.com> | 2015-01-24 20:40:27 +1100 |
---|---|---|
committer | Craig Robbins <kde.psych@gmail.com> | 2015-01-25 15:23:37 +1000 |
commit | ed7c9c4cb83da887a2a7f1b7f5fc1656057977e7 (patch) | |
tree | 62455be3c1be6a0d4040c770a37d8dcc82ad867b /src/settings.h | |
parent | 2c4a5e18619a69159bcace8c03b4ea5642f46836 (diff) | |
download | minetest-ed7c9c4cb83da887a2a7f1b7f5fc1656057977e7.tar.gz minetest-ed7c9c4cb83da887a2a7f1b7f5fc1656057977e7.tar.bz2 minetest-ed7c9c4cb83da887a2a7f1b7f5fc1656057977e7.zip |
Settings fixes Make the GameGlobalShaderConstantSetter use the settings callback (8% perf improvement in game loop) Ensure variable is set Ensure settings callback is threadsafe
Diffstat (limited to 'src/settings.h')
-rw-r--r-- | src/settings.h | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/settings.h b/src/settings.h index 89f7589df..1a7d9ab96 100644 --- a/src/settings.h +++ b/src/settings.h @@ -32,7 +32,7 @@ class Settings; struct NoiseParams; /** function type to register a changed callback */ -typedef void (*setting_changed_callback)(const std::string); +typedef void (*setting_changed_callback)(const std::string, void*); enum ValueType { VALUETYPE_STRING, @@ -204,7 +204,8 @@ public: void clear(); void updateValue(const Settings &other, const std::string &name); void update(const Settings &other); - void registerChangedCallback(std::string name, setting_changed_callback cbf); + void registerChangedCallback(std::string name, setting_changed_callback cbf, void *userdata = NULL); + void deregisterChangedCallback(std::string name, setting_changed_callback cbf, void *userdata = NULL); private: @@ -215,9 +216,12 @@ private: std::map<std::string, SettingsEntry> m_settings; std::map<std::string, SettingsEntry> m_defaults; - std::map<std::string, std::vector<setting_changed_callback> > m_callbacks; - // All methods that access m_settings/m_defaults directly should lock this. - mutable JMutex m_mutex; + + std::map<std::string, std::vector<std::pair<setting_changed_callback,void*> > > m_callbacks; + + mutable JMutex m_callbackMutex; + mutable JMutex m_mutex; // All methods that access m_settings/m_defaults directly should lock this. + }; #endif |