diff options
author | michael-west <michael.west@ettus.com> | 2016-07-14 17:57:15 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2016-09-02 11:10:46 -0700 |
commit | 196e93a387dea47ab8a3ad600b90446e98840a54 (patch) | |
tree | e47bd5509a505b1a2d65dee99b3f50ce2c5d7ff4 /host | |
parent | 2c3f04fa233874d453b52a5b988534322b219f9b (diff) | |
download | uhd-196e93a387dea47ab8a3ad600b90446e98840a54.tar.gz uhd-196e93a387dea47ab8a3ad600b90446e98840a54.tar.bz2 uhd-196e93a387dea47ab8a3ad600b90446e98840a54.zip |
Add thread safety to gps_ctrl cached sensors
Diffstat (limited to 'host')
-rw-r--r-- | host/lib/usrp/gps_ctrl.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
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 <boost/tokenizer.hpp> #include <boost/format.hpp> #include <boost/regex.hpp> +#include <boost/thread/mutex.hpp> #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<std::string, boost::tuple<std::string, boost::system_time, bool> > 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 ... |