Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include support for Windows in 1.0.0 #312

Merged
merged 5 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions rmw_zenoh_cpp/src/detail/graph_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <algorithm>
#include <array>
#include <functional>
#include <limits>
#include <memory>
#include <mutex>
#include <optional>
Expand Down Expand Up @@ -210,48 +211,55 @@ void GraphCache::handle_matched_events_for_put(
EntityEventMap local_entities_with_events = {};
// The entity added may be local with callbacks registered but there
// may be other local entities in the graph that are matched.
std::size_t match_count_for_entity = 0;
int32_t match_count_for_entity = 0;
for (const auto & [_, topic_data_ptr] : topic_qos_map) {
if (is_pub) {
// Count the number of matching subs for each set of qos settings.
match_count_for_entity += topic_data_ptr->subs_.size();
std::size_t sub_size = topic_data_ptr->subs_.size();
if (sub_size > std::numeric_limits<int32_t>::max()) {
RMW_ZENOH_LOG_ERROR_NAMED(
"rmw_zenoh_cpp",
"Too many subscriptions on publisher; assuming 0. Report this bug.");
sub_size = 0;
}
match_count_for_entity += static_cast<int32_t>(sub_size);
// Also iterate through the subs to check if any are local and if update event counters.
for (liveliness::ConstEntityPtr sub_entity : topic_data_ptr->subs_) {
// Update counters only if key expressions match.
if (entity->topic_info()->topic_keyexpr_ ==
sub_entity->topic_info().value().topic_keyexpr_)
{
update_event_counters(
topic_info.name_,
ZENOH_EVENT_SUBSCRIPTION_MATCHED,
static_cast<int32_t>(1));
update_event_counters(topic_info.name_, ZENOH_EVENT_SUBSCRIPTION_MATCHED, 1);
if (is_entity_local(*sub_entity)) {
local_entities_with_events[sub_entity].insert(ZENOH_EVENT_SUBSCRIPTION_MATCHED);
}
}
}
// Update event counters for the new entity->
update_event_counters(
topic_info.name_,
update_event_counters(topic_info.name_,
ZENOH_EVENT_PUBLICATION_MATCHED,
static_cast<int32_t>(match_count_for_entity));
match_count_for_entity);
if (is_entity_local(*entity) && match_count_for_entity > 0) {
local_entities_with_events[entity].insert(ZENOH_EVENT_PUBLICATION_MATCHED);
}
} else {
// Entity is a sub.
// Count the number of matching pubs for each set of qos settings.
match_count_for_entity += topic_data_ptr->pubs_.size();
std::size_t pub_size = topic_data_ptr->pubs_.size();
if (pub_size > std::numeric_limits<int32_t>::max()) {
RMW_ZENOH_LOG_ERROR_NAMED(
"rmw_zenoh_cpp",
"Too many publishers on subscription; assuming 0. Report this bug.");
pub_size = 0;
}
match_count_for_entity += static_cast<int32_t>(pub_size);
// Also iterate through the pubs to check if any are local and if update event counters.
for (liveliness::ConstEntityPtr pub_entity : topic_data_ptr->pubs_) {
// Update counters only if key expressions match.
if (entity->topic_info()->topic_keyexpr_ ==
pub_entity->topic_info().value().topic_keyexpr_)
{
update_event_counters(
topic_info.name_,
ZENOH_EVENT_PUBLICATION_MATCHED,
static_cast<int32_t>(1));
update_event_counters(topic_info.name_, ZENOH_EVENT_PUBLICATION_MATCHED, 1);
if (is_entity_local(*pub_entity)) {
local_entities_with_events[pub_entity].insert(ZENOH_EVENT_PUBLICATION_MATCHED);
}
Expand All @@ -261,7 +269,7 @@ void GraphCache::handle_matched_events_for_put(
update_event_counters(
topic_info.name_,
ZENOH_EVENT_SUBSCRIPTION_MATCHED,
static_cast<int32_t>(match_count_for_entity));
match_count_for_entity);
if (is_entity_local(*entity) && match_count_for_entity > 0) {
local_entities_with_events[entity].insert(ZENOH_EVENT_SUBSCRIPTION_MATCHED);
}
Expand Down
9 changes: 1 addition & 8 deletions rmw_zenoh_cpp/src/detail/rmw_context_impl_s.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,8 @@
#include "rmw/ret_types.h"
#include "rmw/types.h"

#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4099)
#endif
///=============================================================================
class rmw_context_impl_s final
struct rmw_context_impl_s final
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@clalancette was this change to struct intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a warning on Windows, rmw_context_impl_s is defined in the rmw as a struct but we are implementing this as a class.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@clalancette was this change to struct intentional?

Yes, because otherwise Windows complains that it is defined as a struct in rmw.h, but as a class here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Thanks for pointing that out.

{
public:
// Constructor that internally initializes the Zenoh session and other artifacts.
Expand Down Expand Up @@ -99,8 +95,5 @@ class rmw_context_impl_s final
private:
std::shared_ptr<Data> data_{nullptr};
};
#ifdef _MSC_VER
#pragma warning(pop)
#endif

#endif // DETAIL__RMW_CONTEXT_IMPL_S_HPP_
2 changes: 1 addition & 1 deletion rmw_zenoh_cpp/src/detail/zenoh_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ std::optional<uint64_t> zenoh_router_check_attempts()
}
// If the environment variable contains a value, handle it accordingly.
if (envar_value[0] != '\0') {
const auto read_value = std::strtoll(envar_value, nullptr, 10);
const int64_t read_value = std::strtoll(envar_value, nullptr, 10);
if (read_value > 0) {
return read_value;
} else if (read_value < 0) {
Expand Down
Loading