diff --git a/drama/src/rev-mc.c b/drama/src/rev-mc.c index 400c10a..08e3177 100644 --- a/drama/src/rev-mc.c +++ b/drama/src/rev-mc.c @@ -360,13 +360,18 @@ find_row_mask(std::vector &sets, } step_count -= std::min(step_count, step); - std::lock_guard _(lock); if (my_pos > g_base_pos) { - g_base_pos = my_pos; - row_mask = cur_mask; + std::lock_guard _(lock); + if (my_pos > g_base_pos) { + g_base_pos = my_pos; + row_mask = cur_mask; + } } else if (g_base_pos <= g_cur_pos) { - cur_mask = row_mask; - my_pos = g_base_pos; + std::lock_guard _(lock); + if (g_base_pos < g_cur_pos) { + cur_mask = row_mask; + my_pos = g_base_pos; + } } }