summaryrefslogtreecommitdiffstats
path: root/src/can-signals.hpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-02-24 14:14:48 +0000
committerRomain Forlot <romain.forlot@iot.bzh>2017-02-24 14:14:48 +0000
commit9a8dcb99c3efb5b00b0a014e4699655d479d9925 (patch)
tree912d8e9923b4adf71f973239500743e459bed4d3 /src/can-signals.hpp
parent5c0c41e87ed5d1a2de7d336465c3beb3987a299f (diff)
Improve mutex lock logic.
- Use of bracket instead of unlock method - Change some mutex lock scope. - Added subscribed_signals map object mutex to manipulate it safely. Change-Id: I770c0b5701db6b1151511f7360ec31ae6dcc1de9 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src/can-signals.hpp')
-rw-r--r--src/can-signals.hpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/can-signals.hpp b/src/can-signals.hpp
index af110d0d..fb77df5c 100644
--- a/src/can-signals.hpp
+++ b/src/can-signals.hpp
@@ -23,6 +23,8 @@
#include <string>
#include <thread>
#include <linux/can.h>
+#include <mutex>
+#include <condition_variable>
#include "timer.hpp"
#include "openxc.pb.h"
@@ -46,6 +48,13 @@ extern "C"
*/
static std::map<std::string, struct afb_event> subscribed_signals;
+/**
+* @brief Mutex allowing safe manipulation on subscribed_signals map.
+* @desc To ensure that the map object isn't modified when we read it, you
+* have to set this mutex before use subscribed_signals map object.
+*/
+extern std::mutex subscribed_signals_mutex;
+
/** Public: Return the currently active CAN configuration. */
CanMessageSet* getActiveMessageSet();