Avoid data race in modal progress mode

This commit is contained in:
Jonathan G Rennison
2020-04-11 18:23:38 +01:00
parent 1e7a73b2c7
commit e2ab622a14
2 changed files with 19 additions and 4 deletions

View File

@@ -1490,12 +1490,17 @@ void DrawDirtyBlocks()
if (HasModalProgress()) {
/* We are generating the world, so release our rights to the map and
* painting while we are waiting a bit. */
bool is_first_modal_progress_loop = IsFirstModalProgressLoop();
_modal_progress_paint_mutex.unlock();
_modal_progress_work_mutex.unlock();
/* Wait a while and update _realtime_tick so we are given the rights */
if (!IsFirstModalProgressLoop()) CSleep(MODAL_PROGRESS_REDRAW_TIMEOUT);
if (!is_first_modal_progress_loop) CSleep(MODAL_PROGRESS_REDRAW_TIMEOUT);
#if defined(__GNUC__) || defined(__clang__)
__atomic_add_fetch(&_realtime_tick, MODAL_PROGRESS_REDRAW_TIMEOUT, __ATOMIC_RELAXED);
#else
_realtime_tick += MODAL_PROGRESS_REDRAW_TIMEOUT;
#endif
/* Modal progress thread may need blitter access while we are waiting for it. */
VideoDriver::GetInstance()->ReleaseBlitterLock();