From 23cb178b15656dd9f6410264a1c03bf5fb42ed4e Mon Sep 17 00:00:00 2001 From: Yadunund Date: Thu, 18 Apr 2024 14:45:17 +0800 Subject: [PATCH] Lint Signed-off-by: Yadunund --- rmw_zenoh_cpp/src/detail/guard_condition.cpp | 4 +++- rmw_zenoh_cpp/src/detail/rmw_data_types.cpp | 12 +++++++++--- rmw_zenoh_cpp/src/rmw_zenoh.cpp | 18 +++++++++++++----- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/rmw_zenoh_cpp/src/detail/guard_condition.cpp b/rmw_zenoh_cpp/src/detail/guard_condition.cpp index 08e11c69..214dff7e 100644 --- a/rmw_zenoh_cpp/src/detail/guard_condition.cpp +++ b/rmw_zenoh_cpp/src/detail/guard_condition.cpp @@ -39,7 +39,9 @@ void GuardCondition::trigger() } ///============================================================================== -void GuardCondition::attach_condition(std::mutex * condition_mutex, std::condition_variable * condition_variable) +void GuardCondition::attach_condition( + std::mutex * condition_mutex, + std::condition_variable * condition_variable) { std::lock_guard lock(internal_mutex_); condition_mutex_ = condition_mutex; diff --git a/rmw_zenoh_cpp/src/detail/rmw_data_types.cpp b/rmw_zenoh_cpp/src/detail/rmw_data_types.cpp index 6859fbb4..ac48f478 100644 --- a/rmw_zenoh_cpp/src/detail/rmw_data_types.cpp +++ b/rmw_zenoh_cpp/src/detail/rmw_data_types.cpp @@ -63,7 +63,9 @@ size_t rmw_publisher_data_t::get_next_sequence_number() } ///============================================================================= -void rmw_subscription_data_t::attach_condition(std::mutex * condition_mutex, std::condition_variable * condition_variable) +void rmw_subscription_data_t::attach_condition( + std::mutex * condition_mutex, + std::condition_variable * condition_variable) { std::lock_guard lock(update_condition_mutex_); condition_mutex_ = condition_mutex; @@ -155,7 +157,9 @@ bool rmw_service_data_t::query_queue_is_empty() const } ///============================================================================= -void rmw_service_data_t::attach_condition(std::mutex * condition_mutex, std::condition_variable * condition_variable) +void rmw_service_data_t::attach_condition( + std::mutex * condition_mutex, + std::condition_variable * condition_variable) { std::lock_guard lock(update_condition_mutex_); condition_mutex_ = condition_mutex; @@ -333,7 +337,9 @@ bool rmw_client_data_t::reply_queue_is_empty() const } ///============================================================================= -void rmw_client_data_t::attach_condition(std::mutex * condition_mutex, std::condition_variable * condition_variable) +void rmw_client_data_t::attach_condition( + std::mutex * condition_mutex, + std::condition_variable * condition_variable) { std::lock_guard lock(update_condition_mutex_); condition_mutex_ = condition_mutex; diff --git a/rmw_zenoh_cpp/src/rmw_zenoh.cpp b/rmw_zenoh_cpp/src/rmw_zenoh.cpp index 9ff0a2b5..d2245704 100644 --- a/rmw_zenoh_cpp/src/rmw_zenoh.cpp +++ b/rmw_zenoh_cpp/src/rmw_zenoh.cpp @@ -3250,7 +3250,9 @@ rmw_wait( for (size_t i = 0; i < subscriptions->subscriber_count; ++i) { auto sub_data = static_cast(subscriptions->subscribers[i]); if (sub_data != nullptr) { - sub_data->attach_condition(&wait_set_data->condition_mutex, &wait_set_data->condition_variable); + sub_data->attach_condition( + &wait_set_data->condition_mutex, + &wait_set_data->condition_variable); } } } @@ -3261,7 +3263,9 @@ rmw_wait( for (size_t i = 0; i < services->service_count; ++i) { auto serv_data = static_cast(services->services[i]); if (serv_data != nullptr) { - serv_data->attach_condition(&wait_set_data->condition_mutex, &wait_set_data->condition_variable); + serv_data->attach_condition( + &wait_set_data->condition_mutex, + &wait_set_data->condition_variable); } } } @@ -3272,7 +3276,9 @@ rmw_wait( for (size_t i = 0; i < clients->client_count; ++i) { rmw_client_data_t * client_data = static_cast(clients->clients[i]); if (client_data != nullptr) { - client_data->attach_condition(&wait_set_data->condition_mutex, &wait_set_data->condition_variable); + client_data->attach_condition( + &wait_set_data->condition_mutex, + &wait_set_data->condition_variable); } } } @@ -3295,7 +3301,8 @@ rmw_wait( std::unique_lock lock(wait_set_data->condition_mutex); - // We have to check the triggered condition *again* under the lock so we don't miss notifications. + // We have to check the triggered condition *again* under the lock so we + // don't miss notifications. skip_wait = has_triggered_condition( subscriptions, guard_conditions, services, clients, events); @@ -3308,7 +3315,8 @@ rmw_wait( } else { if (wait_timeout->sec != 0 || wait_timeout->nsec != 0) { std::cv_status wait_status = wait_set_data->condition_variable.wait_for( - lock, std::chrono::nanoseconds(wait_timeout->nsec + RCUTILS_S_TO_NS(wait_timeout->sec))); + lock, + std::chrono::nanoseconds(wait_timeout->nsec + RCUTILS_S_TO_NS(wait_timeout->sec))); wait_result = wait_status == std::cv_status::no_timeout; } }