core_timing: Lock CoreTiming event queue while deserializing
To handle those classic asymmetric constructor/destructor side effects
This commit is contained in:
parent
b2531310b4
commit
996ca25a2e
3 changed files with 23 additions and 0 deletions
|
@ -280,6 +280,11 @@ public:
|
|||
|
||||
std::shared_ptr<Timer> GetTimer(std::size_t cpu_id);
|
||||
|
||||
// Used after deserializing to unprotect the event queue.
|
||||
void UnlockEventQueue() {
|
||||
event_queue_locked = false;
|
||||
}
|
||||
|
||||
private:
|
||||
// unordered_map stores each element separately as a linked list node so pointers to
|
||||
// elements remain stable regardless of rehashes/resizing.
|
||||
|
@ -292,6 +297,10 @@ private:
|
|||
// under/overclocking the guest cpu
|
||||
double cpu_clock_scale = 1.0;
|
||||
|
||||
// When true, the event queue can't be modified. Used while deserializing to workaround
|
||||
// destructor side effects.
|
||||
bool event_queue_locked = false;
|
||||
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, const unsigned int file_version) {
|
||||
// event_types set during initialization of other things
|
||||
|
@ -303,6 +312,9 @@ private:
|
|||
} else {
|
||||
ar& current_timer;
|
||||
}
|
||||
if (Archive::is_loading::value) {
|
||||
event_queue_locked = true;
|
||||
}
|
||||
}
|
||||
friend class boost::serialization::access;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue