From: Anthony Geay Date: Mon, 17 Dec 2018 07:28:44 +0000 (+0100) Subject: Make the static counters atomic X-Git-Tag: V9_3_0a1~43 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4fbbb13e5eee64b6f8f6a765dab3db6f71906a85;p=tools%2Fmedcoupling.git Make the static counters atomic --- diff --git a/src/MEDCoupling/MEDCouplingRefCountObject.hxx b/src/MEDCoupling/MEDCouplingRefCountObject.hxx index 5473a9a04..62e859c1c 100644 --- a/src/MEDCoupling/MEDCouplingRefCountObject.hxx +++ b/src/MEDCoupling/MEDCouplingRefCountObject.hxx @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -96,7 +97,7 @@ namespace MEDCoupling protected: virtual ~RefCountObjectOnly(); private: - mutable int _cnt; + mutable std::atomic _cnt; }; class RefCountObject : public RefCountObjectOnly, public BigMemoryObject diff --git a/src/MEDCoupling/MEDCouplingTimeLabel.cxx b/src/MEDCoupling/MEDCouplingTimeLabel.cxx index 2ec3a8827..3b909cdc6 100644 --- a/src/MEDCoupling/MEDCouplingTimeLabel.cxx +++ b/src/MEDCoupling/MEDCouplingTimeLabel.cxx @@ -26,7 +26,7 @@ using namespace MEDCoupling; -std::size_t TimeLabel::GLOBAL_TIME=0; +std::atomic TimeLabel::GLOBAL_TIME(0); TimeLabel::TimeLabel():_time(GLOBAL_TIME++) { diff --git a/src/MEDCoupling/MEDCouplingTimeLabel.hxx b/src/MEDCoupling/MEDCouplingTimeLabel.hxx index cc138c91d..7ab1818f5 100644 --- a/src/MEDCoupling/MEDCouplingTimeLabel.hxx +++ b/src/MEDCoupling/MEDCouplingTimeLabel.hxx @@ -23,6 +23,7 @@ #include "MEDCoupling.hxx" +#include #include namespace MEDCoupling @@ -46,7 +47,7 @@ namespace MEDCoupling MEDCOUPLING_EXPORT void updateTimeWith(const TimeLabel& other) const; MEDCOUPLING_EXPORT void forceTimeOfThis(const TimeLabel& other) const; private: - static std::size_t GLOBAL_TIME; + static std::atomic GLOBAL_TIME; mutable std::size_t _time; };