Fix: thread safety issue during exiting the game #9380
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation / Problem
ThreadSantizer was complaining on exiting the game. It is a bit silly, as it is a boolean value .. but making it a
std::atomic
is also a small effort.Description
Most likely we could change all the loads and stores to
memory_order_relaxed
, as I doubt it really matters honestly. We are pretty resilient against_exit_game
being flipped at the weirdest places.The reason I didn't do it, is because there are roughly 30 places where we load/store
_exit_game
. That maybe highlights a completely different issue in our codebase :PLimitations
std::atomic
. I would think it doesn't matter (at all) in this case, but I would love to be told wrong here :)Checklist for review
Some things are not automated, and forgotten often. This list is a reminder for the reviewers.