mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-25 21:06:58 -05:00
Core: Protect each event from race conditions within it.
This commit is contained in:
parent
9cafb0d912
commit
38e4a144a1
2 changed files with 2 additions and 0 deletions
|
@ -226,6 +226,7 @@ std::optional<s64> CoreTiming::Advance() {
|
|||
event_mutex.unlock();
|
||||
|
||||
if (const auto event_type{evt.type.lock()}) {
|
||||
std::unique_lock<std::mutex> lk(event_type->guard);
|
||||
event_type->callback(evt.user_data, std::chrono::nanoseconds{static_cast<s64>(
|
||||
GetGlobalTimeNs().count() - evt.time)});
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ struct EventType {
|
|||
TimedCallback callback;
|
||||
/// A pointer to the name of the event.
|
||||
const std::string name;
|
||||
mutable std::mutex guard;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue