mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-07 16:49:27 +00:00
Use structs for config callback IDs
This way you can't mix up regular config callback IDs and CPU thread config callback IDs. (It would be rather bad if you did!)
This commit is contained in:
parent
1104b93ee4
commit
7197e3abd0
17 changed files with 56 additions and 27 deletions
|
@ -16,7 +16,7 @@ namespace Config
|
|||
using Layers = std::map<LayerType, std::shared_ptr<Layer>>;
|
||||
|
||||
static Layers s_layers;
|
||||
static std::vector<std::pair<size_t, ConfigChangedCallback>> s_callbacks;
|
||||
static std::vector<std::pair<ConfigChangedCallbackID, 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;
|
||||
|
@ -65,15 +65,15 @@ void RemoveLayer(LayerType layer)
|
|||
OnConfigChanged();
|
||||
}
|
||||
|
||||
size_t AddConfigChangedCallback(ConfigChangedCallback func)
|
||||
ConfigChangedCallbackID AddConfigChangedCallback(ConfigChangedCallback func)
|
||||
{
|
||||
const size_t callback_id = s_next_callback_id;
|
||||
const ConfigChangedCallbackID 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)
|
||||
void RemoveConfigChangedCallback(ConfigChangedCallbackID callback_id)
|
||||
{
|
||||
for (auto it = s_callbacks.begin(); it != s_callbacks.end(); ++it)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue