sys: Make sure deferred call adding is thread safe
This commit is contained in:
parent
050e17298a
commit
29ded2483c
@ -172,15 +172,17 @@ namespace hex {
|
||||
return { unlocalizedName, maxValue };
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::function<void()>> s_deferredCalls;
|
||||
|
||||
void doLater(const std::function<void()> &function) {
|
||||
static std::mutex tasksMutex;
|
||||
std::scoped_lock lock(tasksMutex);
|
||||
|
||||
getDeferredCalls().push_back(function);
|
||||
}
|
||||
|
||||
std::vector<std::function<void()>> &getDeferredCalls() {
|
||||
return s_deferredCalls;
|
||||
static std::vector<std::function<void()>> deferredCalls;
|
||||
|
||||
return deferredCalls;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user