aboutsummaryrefslogtreecommitdiffstats
path: root/src/can-utils.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-utils.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-utils.hpp')
-rw-r--r--src/can-utils.hpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/can-utils.hpp b/src/can-utils.hpp
index 11e19f3..76dc75b 100644
--- a/src/can-utils.hpp
+++ b/src/can-utils.hpp
@@ -221,7 +221,9 @@ class can_bus_t {
int conf_file_; /*!< conf_file_ - configuration file handle used to initialize can_bus_dev_t objects.*/
std::thread th_decoding_; /*!< thread that'll handle decoding a can frame */
+ bool is_decoding_; /*!< boolean member controling thread while loop*/
std::thread th_pushing_; /*!< thread that'll handle pushing decoded can frame to subscribers */
+ bool is_pushing_; /*!< boolean member controling thread while loop*/
bool has_can_message_; /*!< boolean members that control whether or not there is can_message into the queue */
std::queue <can_message_t> can_message_q_; /*!< queue that'll store can_message_t to decoded */
@@ -259,6 +261,32 @@ class can_bus_t {
void start_threads();
/**
+ * @brief Will stop all threads holded by can_bus_t object
+ * which are decoding and pushing threads.
+ */
+ void stop_threads();
+
+ /**
+ * @brief Telling if the decoding thread is running.
+ * This is the boolean value on which the while loop
+ * take its condition. Set it to false will stop the
+ * according thread.
+ *
+ * @return true if decoding thread is running, false if not.
+ */
+ bool is_decoding();
+
+ /**
+ * @brief Telling if the pushing thread is running
+ * This is the boolean value on which the while loop
+ * take its condition. Set it to false will stop the
+ * according thread.
+ *
+ * @return true if pushing thread is running, false if not.
+ */
+ bool is_pushing();
+
+ /**
* @brief Return first can_message_t on the queue
*
* @return a can_message_t
@@ -341,8 +369,11 @@ class can_bus_dev_t {
/**
* @brief Telling if the reading thread is running
+ * This is the boolean value on which the while loop
+ * take its condition. Set it to false will stop the
+ * according thread.
*
- * @return true if read is running, false if not.
+ * @return true if reading thread is running, false if not.
*/
bool is_running();