-
Notifications
You must be signed in to change notification settings - Fork 484
Feature/available capacity of ipm #2173
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
Changes from 8 commits
947fe68
6e04274
3315396
155312b
7fdf026
d7429d7
58666fa
67e4b20
bb8209a
e6da9ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -225,5 +225,55 @@ IntraProcessManager::can_communicate( | |
| return true; | ||
| } | ||
|
|
||
| size_t | ||
| IntraProcessManager::lowest_available_capacity(const uint64_t intra_process_publisher_id) const | ||
| { | ||
| size_t capacity = std::numeric_limits<size_t>::max(); | ||
|
|
||
| auto publisher_it = pub_to_subs_.find(intra_process_publisher_id); | ||
| if (publisher_it == pub_to_subs_.end()) { | ||
| // Publisher is either invalid or no longer exists. | ||
| RCLCPP_WARN( | ||
| rclcpp::get_logger("rclcpp"), | ||
| "Calling lowest_available_capacity for invalid or no longer existing publisher id"); | ||
| return 0u; | ||
| } | ||
|
|
||
| if (publisher_it->second.take_shared_subscriptions.empty() && | ||
| publisher_it->second.take_ownership_subscriptions.empty()) | ||
| { | ||
| // no subscriptions available | ||
| return 0u; | ||
| } | ||
|
|
||
| for (const auto sub_id : publisher_it->second.take_shared_subscriptions) { | ||
| capacity = std::min(capacity, available_capacity(sub_id)); | ||
| } | ||
|
|
||
| for (const auto sub_id : publisher_it->second.take_ownership_subscriptions) { | ||
| capacity = std::min(capacity, available_capacity(sub_id)); | ||
| } | ||
|
|
||
| return capacity; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there could be possibility that this returns
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's expected behavior. If not subscriptions are present, the buffer is "free" -> return max. value. To check for the number of (intra-process) subscriptions there is another method.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so that means that publisher actually can write the maximum number of data in the buffer? i believe that what it means to return the maximum number here as interface, and what user application expects. |
||
| } | ||
|
|
||
| size_t | ||
| IntraProcessManager::available_capacity(const uint64_t intra_process_subscription_id) const | ||
| { | ||
| auto subscription_it = subscriptions_.find(intra_process_subscription_id); | ||
| if (subscription_it != subscriptions_.end()) { | ||
| auto subscription = subscription_it->second.lock(); | ||
| if (subscription) { | ||
| return subscription->available_capacity(); | ||
| } | ||
| } | ||
|
|
||
| // Subscription is either invalid or no longer exists. | ||
| RCLCPP_WARN( | ||
| rclcpp::get_logger("rclcpp"), | ||
| "Calling available_capacity for invalid or no longer existing subscription id"); | ||
|
|
||
| return 0; | ||
| } | ||
| } // namespace experimental | ||
| } // namespace rclcpp | ||
Uh oh!
There was an error while loading. Please reload this page.