From 61bc8d12d39cb31303ec9162b1ca8a015d896192 Mon Sep 17 00:00:00 2001 From: Joost VandeVondele Date: Fri, 18 Sep 2020 23:06:45 +0200 Subject: [PATCH] Fix some races in learning declare a few variables atomic. Other races remain... --- src/learn/learn.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/learn/learn.cpp b/src/learn/learn.cpp index 6d0a777d..6142ce6b 100644 --- a/src/learn/learn.cpp +++ b/src/learn/learn.cpp @@ -695,14 +695,14 @@ namespace Learner uint64_t last_done; // If total_read exceeds this value, update_weights() and calculate mse. - uint64_t next_update_weights; + std::atomic next_update_weights; uint64_t save_count; // Do not shuffle when reading the phase. bool no_shuffle; - bool stop_flag; + std::atomic stop_flag; vector hash; @@ -785,7 +785,7 @@ namespace Learner // Mini batch size size. Be sure to set it on the side that uses this class. uint64_t mini_batch_size = LEARN_MINI_BATCH_SIZE; - bool stop_flag; + std::atomic stop_flag; // Discount rate double discount_rate;