summaryrefslogtreecommitdiffstats
path: root/src/can_reader.cpp
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_reader.cpp
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_reader.cpp')
-rw-r--r--src/can_reader.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/can_reader.cpp b/src/can_reader.cpp
index 018c7cba..7ae981b8 100644
--- a/src/can_reader.cpp
+++ b/src/can_reader.cpp
@@ -29,9 +29,10 @@ void can_reader(can_bus_dev_t &can_bus_dev, can_bus_t& can_bus)
{
can_message.convert_from_canfd_frame(can_bus_dev.read());
- std::lock_guard<std::mutex> can_message_lock(can_message_mutex);
+ {
+ std::lock_guard<std::mutex> can_message_lock(can_message_mutex);
can_bus.push_new_can_message(can_message);
- can_message_mutex.unlock();
+ }
new_can_message.notify_one();
}
} \ No newline at end of file