From 9a8dcb99c3efb5b00b0a014e4699655d479d9925 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Fri, 24 Feb 2017 14:14:48 +0000 Subject: 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 --- src/can-utils.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/can-utils.cpp') 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() { -- cgit 1.2.3-korg