GeonBit icon indicating copy to clipboard operation
GeonBit copied to clipboard

Update thread-safe implementation for GameFiles

Open nguyenlamlll opened this issue 8 years ago • 3 comments

Locking on the value of a private static variable to prevent thread-safety violations and performance issues.

nguyenlamlll avatar Sep 04 '17 12:09 nguyenlamlll

I'll take a look when I'll have time, probably during the next weekend.. Thanks!

RonenNess avatar Sep 10 '17 09:09 RonenNess

OK overall this seems like an harmless change, but could you explain a bit what problem it solves and how is this improving performance? Thanks!

RonenNess avatar Sep 16 '17 12:09 RonenNess

I haven't looked at the full engine yet but so far what I've found and based on what I've experienced, the previous version implemented a non-safe singleton pattern. We may try to multi-thread saving some game files in the future so these changes ensure that. If there isn't a lock, 2 or more threads can jump into a single if statement providing they bypass the check but haven't created an instance. I'm sorry if this is quite trivial.

nguyenlamlll avatar Sep 18 '17 02:09 nguyenlamlll