3737namespace fuse_core
3838{
3939
40- CallbackAdapter::CallbackAdapter (std::shared_ptr<rclcpp::Context> context_ptr)
40+ CallbackAdapter::CallbackAdapter (std::shared_ptr<rclcpp::Context> const & context_ptr)
41+ : gc_(rcl_get_zero_initialized_guard_condition())
4142{
42- rcl_guard_condition_options_t guard_condition_options = rcl_guard_condition_get_default_options ();
43+ rcl_guard_condition_options_t const guard_condition_options = rcl_guard_condition_get_default_options ();
4344
4445 // Guard condition is used by the wait set to handle execute-or-not logic
45- gc_ = rcl_get_zero_initialized_guard_condition ();
4646 if (RCL_RET_OK != rcl_guard_condition_init (&gc_, context_ptr->get_rcl_context ().get (), guard_condition_options))
4747 {
4848 throw std::runtime_error (" Could not init guard condition for callback waitable." );
@@ -74,7 +74,7 @@ bool CallbackAdapter::is_ready(rcl_wait_set_t const& wait_set)
7474 */
7575void CallbackAdapter::add_to_wait_set (rcl_wait_set_t & wait_set)
7676{
77- if (RCL_RET_OK != rcl_wait_set_add_guard_condition (&wait_set, &gc_, NULL ))
77+ if (RCL_RET_OK != rcl_wait_set_add_guard_condition (&wait_set, &gc_, nullptr ))
7878 {
7979 RCLCPP_WARN (rclcpp::get_logger (" fuse" ), " Could not add callback waitable to wait set." );
8080 }
@@ -89,7 +89,7 @@ std::shared_ptr<void> CallbackAdapter::take_data()
8989 std::shared_ptr<CallbackWrapperBase> cb_wrapper = nullptr ;
9090 // fetch the callback ptr and release the lock without spending time in the callback
9191 {
92- std::lock_guard<std::mutex> lock (queue_mutex_);
92+ std::lock_guard<std::mutex> const lock (queue_mutex_);
9393 if (!callback_queue_.empty ())
9494 {
9595 cb_wrapper = callback_queue_.front ();
@@ -122,7 +122,7 @@ void CallbackAdapter::execute(std::shared_ptr<void> const& data)
122122
123123void CallbackAdapter::addCallback (const std::shared_ptr<CallbackWrapperBase>& callback)
124124{
125- std::lock_guard<std::mutex> lock (queue_mutex_);
125+ std::lock_guard<std::mutex> const lock (queue_mutex_);
126126 callback_queue_.push_back (callback);
127127 if (RCL_RET_OK != rcl_trigger_guard_condition (&gc_))
128128 {
@@ -134,7 +134,7 @@ void CallbackAdapter::addCallback(const std::shared_ptr<CallbackWrapperBase>& ca
134134
135135void CallbackAdapter::addCallback (std::shared_ptr<CallbackWrapperBase>&& callback)
136136{
137- std::lock_guard<std::mutex> lock (queue_mutex_);
137+ std::lock_guard<std::mutex> const lock (queue_mutex_);
138138 callback_queue_.push_back (std::move (callback));
139139 if (RCL_RET_OK != rcl_trigger_guard_condition (&gc_))
140140 {
@@ -146,7 +146,7 @@ void CallbackAdapter::addCallback(std::shared_ptr<CallbackWrapperBase>&& callbac
146146
147147void CallbackAdapter::removeAllCallbacks ()
148148{
149- std::lock_guard<std::mutex> lock (queue_mutex_);
149+ std::lock_guard<std::mutex> const lock (queue_mutex_);
150150 callback_queue_.clear ();
151151}
152152
0 commit comments