Game Config Manager: handle clearing image cache in main thread
See comment for explanation. This was a better solution that adding mutexes to the cache accessors; that had performance downsides.
This commit is contained in:
parent
b8ad791a1d
commit
011cbfe3b8
1 changed files with 6 additions and 1 deletions
|
@ -570,8 +570,13 @@ void game_config_manager::load_game_config_for_game(
|
|||
throw;
|
||||
}
|
||||
|
||||
image::flush_cache();
|
||||
// This needs to be done in the main thread since this function (load_game_config_for_game)
|
||||
// might be called from a loading screen worker thread (and currently is, in fact). If the
|
||||
// image cache is purged from the worker thread, there's a possibility for a data race where
|
||||
// the main thread accesses the image cache and the worker thread simultaneously clears it.
|
||||
events::call_in_main_thread([]() { image::flush_cache(); });
|
||||
}
|
||||
|
||||
void game_config_manager::load_game_config_for_create(bool is_mp, bool is_test)
|
||||
{
|
||||
game_config::scoped_preproc_define multiplayer("MULTIPLAYER", is_mp);
|
||||
|
|
Loading…
Add table
Reference in a new issue