diff --git a/src/capture_base.cpp b/src/capture_base.cpp index 2852f011c3be43e25d04fb14d7d375a29de35f68..e2dd4476edcc3634420714d75e4692f651b1261f 100644 --- a/src/capture_base.cpp +++ b/src/capture_base.cpp @@ -3,7 +3,7 @@ namespace wolf{ -unsigned int CaptureBase::capture_id_count_ = 0; +std::atomic_uint CaptureBase::capture_id_count_(0); CaptureBase::CaptureBase(const std::string& _type, const TimeStamp& _ts, SensorBasePtr _sensor_ptr) : NodeBase("CAPTURE", _type), diff --git a/src/capture_base.h b/src/capture_base.h index 42447ae2bff118a539a41c712c69e6f6ac15a7d1..4b3046e912ba235398dd3ff3be004f8371cc0842 100644 --- a/src/capture_base.h +++ b/src/capture_base.h @@ -23,7 +23,7 @@ class CaptureBase : public NodeBase, public std::enable_shared_from_this<Capture FrameBaseWPtr frame_ptr_; FeatureBaseList feature_list_; - static unsigned int capture_id_count_; + static std::atomic_uint capture_id_count_; protected: unsigned int capture_id_; diff --git a/src/node_base.cpp b/src/node_base.cpp index f6f4ceb5322b10c6432c348927e911c598ff73fd..387b1dc3f7b233e642d805184ce46a3d91bd370a 100644 --- a/src/node_base.cpp +++ b/src/node_base.cpp @@ -3,6 +3,6 @@ namespace wolf { //init static node counter -unsigned int NodeBase::node_id_count_ = 0; +std::atomic_uint NodeBase::node_id_count_(0); } // namespace wolf diff --git a/src/node_base.h b/src/node_base.h index c64bbc90086099b7ccf90a0484795b8b39dc8685..70cfc6569cc60db9dcdc1ac93800b1c8b74a1720 100644 --- a/src/node_base.h +++ b/src/node_base.h @@ -4,6 +4,8 @@ // Wolf includes #include "wolf.h" +// std includes +#include <atomic> namespace wolf { @@ -54,7 +56,7 @@ namespace wolf { class NodeBase { private: - static unsigned int node_id_count_; ///< Object counter (acts as simple ID factory) + static std::atomic_uint node_id_count_; ///< Object counter (acts as simple ID factory) protected: ProblemWPtr problem_ptr_;