i3wangyi commented on a change in pull request #363: Fix the race condition while Helix refresh cluster status cache. URL: https://github.com/apache/helix/pull/363#discussion_r308872667
########## File path: helix-core/src/main/java/org/apache/helix/controller/dataproviders/BaseControllerDataProvider.java ########## @@ -82,7 +84,7 @@ private ExecutorService _asyncTasksThreadPool; // A map recording what data has changed - protected Map<HelixConstants.ChangeType, Boolean> _propertyDataChangedMap; + protected Map<HelixConstants.ChangeType, AtomicBoolean> _propertyDataChangedMap; Review comment: @jiajunwang I know it, the context is not obviously known to everyone. @kaisun2000 The real reason is for the sake of performance, we want to a lock-free condition where the `notifyDataChange` runs faster (it simply sets a flag without acquiring lock). In the other hand, the checker (waits for the condition) needs to have the update-to-date information in the multi-threading world. AtomicBoolean is the recommended way to avoid lock and achieve the goal. Some similar discussions are talked about here https://stackoverflow.com/questions/32935548/condition-variable-without-mutex-in-a-lock-free-implementation ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services