Avoid data race in modal progress mode
This commit is contained in:
@@ -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();
|
||||
|
Reference in New Issue
Block a user