From 196e93a387dea47ab8a3ad600b90446e98840a54 Mon Sep 17 00:00:00 2001 From: michael-west Date: Thu, 14 Jul 2016 17:57:15 -0700 Subject: Add thread safety to gps_ctrl cached sensors --- host/lib/usrp/gps_ctrl.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'host') diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp index 207ef10ab..32ed80dc3 100644 --- a/host/lib/usrp/gps_ctrl.cpp +++ b/host/lib/usrp/gps_ctrl.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include "boost/tuple/tuple.hpp" #include "boost/foreach.hpp" @@ -49,8 +50,10 @@ gps_ctrl::~gps_ctrl(void){ class gps_ctrl_impl : public gps_ctrl{ private: std::map > sensors; + boost::mutex cache_mutex; std::string get_cached_sensor(const std::string sensor, const int freshness, const bool once, const bool touch=true) { + boost::mutex::scoped_lock lock(cache_mutex); boost::system_time time = boost::get_system_time(); try { // this is nasty ... -- cgit v1.2.3