summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Config/Config.cpp
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2021-12-27 00:16:24 -0500
committerGitHub <noreply@github.com>2021-12-27 00:16:24 -0500
commit66411571fa52c400b0a3418e5ef6dd33f2869eb9 (patch)
tree2ba344faa10c556a3002cd863e3d7a30784b00d0 /Source/Core/Common/Config/Config.cpp
parent8fcf1bfaa079b02cb8f6084a6a34e0c2214e7405 (diff)
parent7625cb7aca314b36008a4eb11b23151ccb93f2c1 (diff)
Merge pull request #10293 from AdmiralCurtiss/config-port-cpu-overclock
Config: Port CPU overclock setting to new config.
Diffstat (limited to 'Source/Core/Common/Config/Config.cpp')
-rw-r--r--Source/Core/Common/Config/Config.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/Source/Core/Common/Config/Config.cpp b/Source/Core/Common/Config/Config.cpp
index 5943f3d067..67b21ea33b 100644
--- a/Source/Core/Common/Config/Config.cpp
+++ b/Source/Core/Common/Config/Config.cpp
@@ -5,17 +5,19 @@
#include <algorithm>
#include <atomic>
-#include <list>
#include <map>
#include <mutex>
#include <shared_mutex>
+#include <utility>
+#include <vector>
namespace Config
{
using Layers = std::map<LayerType, std::shared_ptr<Layer>>;
static Layers s_layers;
-static std::list<ConfigChangedCallback> s_callbacks;
+static std::vector<std::pair<size_t, ConfigChangedCallback>> s_callbacks;
+static size_t s_next_callback_id = 0;
static u32 s_callback_guards = 0;
static std::atomic<u64> s_config_version = 0;
@@ -63,9 +65,24 @@ void RemoveLayer(LayerType layer)
OnConfigChanged();
}
-void AddConfigChangedCallback(ConfigChangedCallback func)
+size_t AddConfigChangedCallback(ConfigChangedCallback func)
{
- s_callbacks.emplace_back(std::move(func));
+ const size_t callback_id = s_next_callback_id;
+ ++s_next_callback_id;
+ s_callbacks.emplace_back(std::make_pair(callback_id, std::move(func)));
+ return callback_id;
+}
+
+void RemoveConfigChangedCallback(size_t callback_id)
+{
+ for (auto it = s_callbacks.begin(); it != s_callbacks.end(); ++it)
+ {
+ if (it->first == callback_id)
+ {
+ s_callbacks.erase(it);
+ return;
+ }
+ }
}
void OnConfigChanged()
@@ -79,7 +96,7 @@ void OnConfigChanged()
return;
for (const auto& callback : s_callbacks)
- callback();
+ callback.second();
}
u64 GetConfigVersion()