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:
JosJuice
2023-08-16 21:37:12 +02:00
parent 1104b93ee4
commit 7197e3abd0
17 changed files with 56 additions and 27 deletions

View File

@ -15,6 +15,14 @@
namespace Config
{
struct ConfigChangedCallbackID
{
size_t id = -1;
bool operator==(const ConfigChangedCallbackID&) const = default;
bool operator!=(const ConfigChangedCallbackID&) const = default;
};
using ConfigChangedCallback = std::function<void()>;
// Layer management
@ -24,8 +32,8 @@ void RemoveLayer(LayerType layer);
// Returns an ID that can be passed to RemoveConfigChangedCallback().
// The callback may be called from any thread.
size_t AddConfigChangedCallback(ConfigChangedCallback func);
void RemoveConfigChangedCallback(size_t callback_id);
ConfigChangedCallbackID AddConfigChangedCallback(ConfigChangedCallback func);
void RemoveConfigChangedCallback(ConfigChangedCallbackID callback_id);
void OnConfigChanged();
// Returns the number of times the config has changed in the current execution of the program