diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-02-24 14:14:48 +0000 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-02-24 14:14:48 +0000 |
commit | 9a8dcb99c3efb5b00b0a014e4699655d479d9925 (patch) | |
tree | 912d8e9923b4adf71f973239500743e459bed4d3 /src/can-utils.cpp | |
parent | 5c0c41e87ed5d1a2de7d336465c3beb3987a299f (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-utils.cpp')
-rw-r--r-- | src/can-utils.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/can-utils.cpp b/src/can-utils.cpp index c6f2d575..0d52bbe4 100644 --- a/src/can-utils.cpp +++ b/src/can-utils.cpp @@ -162,16 +162,33 @@ canfd_frame can_message_t::convert_to_canfd_frame() *********************************************************************************/ can_bus_t::can_bus_t(int& conf_file) - : conf_file_{conf_file} + : conf_file_{conf_file} { } void can_bus_t::start_threads() { th_decoding_ = std::thread(can_decode_message, std::ref(*this)); + is_decoding_ = true; th_pushing_ = std::thread(can_event_push, std::ref(*this)); + is_pushing_ = true; } +void can_bus_t::stop_threads() +{ + is_decoding_ = false; + is_pushing_ = false; +} + +bool can_bus_t::is_decoding() +{ + return is_decoding_; +} + +bool can_bus_t::is_pushing() +{ + return is_pushing_; +} int can_bus_t::init_can_dev() { |