Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
Signed-off-by: Yadunund <[email protected]>
  • Loading branch information
Yadunund committed Apr 18, 2024
1 parent f65940e commit 23cb178
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
4 changes: 3 additions & 1 deletion rmw_zenoh_cpp/src/detail/guard_condition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::mutex> lock(internal_mutex_);
condition_mutex_ = condition_mutex;
Expand Down
12 changes: 9 additions & 3 deletions rmw_zenoh_cpp/src/detail/rmw_data_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::mutex> lock(update_condition_mutex_);
condition_mutex_ = condition_mutex;
Expand Down Expand Up @@ -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<std::mutex> lock(update_condition_mutex_);
condition_mutex_ = condition_mutex;
Expand Down Expand Up @@ -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<std::mutex> lock(update_condition_mutex_);
condition_mutex_ = condition_mutex;
Expand Down
18 changes: 13 additions & 5 deletions rmw_zenoh_cpp/src/rmw_zenoh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3250,7 +3250,9 @@ rmw_wait(
for (size_t i = 0; i < subscriptions->subscriber_count; ++i) {
auto sub_data = static_cast<rmw_subscription_data_t *>(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);
}
}
}
Expand All @@ -3261,7 +3263,9 @@ rmw_wait(
for (size_t i = 0; i < services->service_count; ++i) {
auto serv_data = static_cast<rmw_service_data_t *>(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);
}
}
}
Expand All @@ -3272,7 +3276,9 @@ rmw_wait(
for (size_t i = 0; i < clients->client_count; ++i) {
rmw_client_data_t * client_data = static_cast<rmw_client_data_t *>(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);
}
}
}
Expand All @@ -3295,7 +3301,8 @@ rmw_wait(

std::unique_lock<std::mutex> 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);

Expand All @@ -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;
}
}
Expand Down

0 comments on commit 23cb178

Please sign in to comment.