From a87419d9848e2337708c4eb582b7f4baede8549d Mon Sep 17 00:00:00 2001 From: Mikael Arguedas Date: Wed, 22 Nov 2017 14:04:52 -0800 Subject: [PATCH 1/5] rename *waitset* to *wait_set* --- rmw_fastrtps_cpp/src/{rmw_waitset.cpp => rmw_wait_set.cpp} | 0 .../types/{custom_waitset_info.hpp => custom_wait_set_info.hpp} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename rmw_fastrtps_cpp/src/{rmw_waitset.cpp => rmw_wait_set.cpp} (100%) rename rmw_fastrtps_cpp/src/types/{custom_waitset_info.hpp => custom_wait_set_info.hpp} (100%) diff --git a/rmw_fastrtps_cpp/src/rmw_waitset.cpp b/rmw_fastrtps_cpp/src/rmw_wait_set.cpp similarity index 100% rename from rmw_fastrtps_cpp/src/rmw_waitset.cpp rename to rmw_fastrtps_cpp/src/rmw_wait_set.cpp diff --git a/rmw_fastrtps_cpp/src/types/custom_waitset_info.hpp b/rmw_fastrtps_cpp/src/types/custom_wait_set_info.hpp similarity index 100% rename from rmw_fastrtps_cpp/src/types/custom_waitset_info.hpp rename to rmw_fastrtps_cpp/src/types/custom_wait_set_info.hpp From 8db2113101690d226adf606065de2658b2198ca2 Mon Sep 17 00:00:00 2001 From: Mikael Arguedas Date: Wed, 22 Nov 2017 14:07:11 -0800 Subject: [PATCH 2/5] waitset -> wait_set --- rmw_fastrtps_cpp/CMakeLists.txt | 2 +- rmw_fastrtps_cpp/src/rmw_wait.cpp | 24 +++++----- rmw_fastrtps_cpp/src/rmw_wait_set.cpp | 68 +++++++++++++-------------- 3 files changed, 47 insertions(+), 47 deletions(-) diff --git a/rmw_fastrtps_cpp/CMakeLists.txt b/rmw_fastrtps_cpp/CMakeLists.txt index 35273c27a..844c3a35d 100644 --- a/rmw_fastrtps_cpp/CMakeLists.txt +++ b/rmw_fastrtps_cpp/CMakeLists.txt @@ -79,7 +79,7 @@ add_library(rmw_fastrtps_cpp src/rmw_topic_names_and_types.cpp src/rmw_trigger_guard_condition.cpp src/rmw_wait.cpp - src/rmw_waitset.cpp + src/rmw_wait_set.cpp src/ros_message_serialization.cpp src/type_support_common.cpp ) diff --git a/rmw_fastrtps_cpp/src/rmw_wait.cpp b/rmw_fastrtps_cpp/src/rmw_wait.cpp index 0cbb441c3..c4056cc97 100644 --- a/rmw_fastrtps_cpp/src/rmw_wait.cpp +++ b/rmw_fastrtps_cpp/src/rmw_wait.cpp @@ -20,12 +20,12 @@ #include "rmw_fastrtps_cpp/custom_client_info.hpp" #include "rmw_fastrtps_cpp/custom_service_info.hpp" #include "rmw_fastrtps_cpp/custom_subscriber_info.hpp" -#include "types/custom_waitset_info.hpp" +#include "types/custom_wait_set_info.hpp" #include "types/guard_condition.hpp" // helper function for wait bool -check_waitset_for_data( +check_wait_set_for_data( const rmw_subscriptions_t * subscriptions, const rmw_guard_conditions_t * guard_conditions, const rmw_services_t * services, @@ -82,26 +82,26 @@ rmw_wait( rmw_guard_conditions_t * guard_conditions, rmw_services_t * services, rmw_clients_t * clients, - rmw_waitset_t * waitset, + rmw_wait_set_t * wait_set, const rmw_time_t * wait_timeout) { - if (!waitset) { + if (!wait_set) { RMW_SET_ERROR_MSG("Waitset handle is null"); return RMW_RET_ERROR; } - CustomWaitsetInfo * waitset_info = static_cast(waitset->data); - if (!waitset_info) { + CustomWaitsetInfo * wait_set_info = static_cast(wait_set->data); + if (!wait_set_info) { RMW_SET_ERROR_MSG("Waitset info struct is null"); return RMW_RET_ERROR; } - std::mutex * conditionMutex = &waitset_info->condition_mutex; - std::condition_variable * conditionVariable = &waitset_info->condition; + std::mutex * conditionMutex = &wait_set_info->condition_mutex; + std::condition_variable * conditionVariable = &wait_set_info->condition; if (!conditionMutex) { - RMW_SET_ERROR_MSG("Mutex for waitset was null"); + RMW_SET_ERROR_MSG("Mutex for wait_set was null"); return RMW_RET_ERROR; } if (!conditionVariable) { - RMW_SET_ERROR_MSG("Condition variable for waitset was null"); + RMW_SET_ERROR_MSG("Condition variable for wait_set was null"); return RMW_RET_ERROR; } @@ -196,7 +196,7 @@ rmw_wait( conditionVariable->wait(lock); } else { auto predicate = [subscriptions, guard_conditions, services, clients]() { - return check_waitset_for_data(subscriptions, guard_conditions, services, clients); + return check_wait_set_for_data(subscriptions, guard_conditions, services, clients); }; auto n = std::chrono::duration_cast( std::chrono::seconds(wait_timeout->sec)); @@ -215,7 +215,7 @@ rmw_wait( // Even if this was a non-blocking wait, signal a timeout if there's no data. // This makes the return behavior consistent with rcl expectations for zero timeout value. // Do this before detaching the listeners because the data gets cleared for guard conditions. - bool hasData = check_waitset_for_data(subscriptions, guard_conditions, services, clients); + bool hasData = check_wait_set_for_data(subscriptions, guard_conditions, services, clients); if (!hasData && wait_timeout && wait_timeout->sec == 0 && wait_timeout->nsec == 0) { timeout = true; } diff --git a/rmw_fastrtps_cpp/src/rmw_wait_set.cpp b/rmw_fastrtps_cpp/src/rmw_wait_set.cpp index 478bd1818..205ba355b 100644 --- a/rmw_fastrtps_cpp/src/rmw_wait_set.cpp +++ b/rmw_fastrtps_cpp/src/rmw_wait_set.cpp @@ -18,78 +18,78 @@ #include "rmw/impl/cpp/macros.hpp" #include "rmw_fastrtps_cpp/identifier.hpp" -#include "types/custom_waitset_info.hpp" +#include "types/custom_wait_set_info.hpp" extern "C" { -rmw_waitset_t * -rmw_create_waitset(size_t max_conditions) +rmw_wait_set_t * +rmw_create_wait_set(size_t max_conditions) { (void)max_conditions; - rmw_waitset_t * waitset = rmw_waitset_allocate(); - CustomWaitsetInfo * waitset_info = nullptr; + rmw_wait_set_t * wait_set = rmw_wait_set_allocate(); + CustomWaitsetInfo * wait_set_info = nullptr; // From here onward, error results in unrolling in the goto fail block. - if (!waitset) { - RMW_SET_ERROR_MSG("failed to allocate waitset"); + if (!wait_set) { + RMW_SET_ERROR_MSG("failed to allocate wait_set"); goto fail; } - waitset->implementation_identifier = eprosima_fastrtps_identifier; - waitset->data = rmw_allocate(sizeof(CustomWaitsetInfo)); + wait_set->implementation_identifier = eprosima_fastrtps_identifier; + wait_set->data = rmw_allocate(sizeof(CustomWaitsetInfo)); // This should default-construct the fields of CustomWaitsetInfo - waitset_info = static_cast(waitset->data); - RMW_TRY_PLACEMENT_NEW(waitset_info, waitset_info, goto fail, CustomWaitsetInfo, ) - if (!waitset_info) { - RMW_SET_ERROR_MSG("failed to construct waitset info struct"); + wait_set_info = static_cast(wait_set->data); + RMW_TRY_PLACEMENT_NEW(wait_set_info, wait_set_info, goto fail, CustomWaitsetInfo, ) + if (!wait_set_info) { + RMW_SET_ERROR_MSG("failed to construct wait_set info struct"); goto fail; } - return waitset; + return wait_set; fail: - if (waitset) { - if (waitset->data) { + if (wait_set) { + if (wait_set->data) { RMW_TRY_DESTRUCTOR_FROM_WITHIN_FAILURE( - waitset_info->~CustomWaitsetInfo(), waitset_info) - rmw_free(waitset->data); + wait_set_info->~CustomWaitsetInfo(), wait_set_info) + rmw_free(wait_set->data); } - rmw_waitset_free(waitset); + rmw_wait_set_free(wait_set); } return nullptr; } rmw_ret_t -rmw_destroy_waitset(rmw_waitset_t * waitset) +rmw_destroy_wait_set(rmw_wait_set_t * wait_set) { - if (!waitset) { - RMW_SET_ERROR_MSG("waitset handle is null"); + if (!wait_set) { + RMW_SET_ERROR_MSG("wait_set handle is null"); return RMW_RET_ERROR; } RMW_CHECK_TYPE_IDENTIFIERS_MATCH( - waitset handle, - waitset->implementation_identifier, eprosima_fastrtps_identifier, + wait_set handle, + wait_set->implementation_identifier, eprosima_fastrtps_identifier, return RMW_RET_ERROR) auto result = RMW_RET_OK; - auto waitset_info = static_cast(waitset->data); - if (!waitset_info) { - RMW_SET_ERROR_MSG("waitset info is null"); + auto wait_set_info = static_cast(wait_set->data); + if (!wait_set_info) { + RMW_SET_ERROR_MSG("wait_set info is null"); return RMW_RET_ERROR; } - std::mutex * conditionMutex = &waitset_info->condition_mutex; + std::mutex * conditionMutex = &wait_set_info->condition_mutex; if (!conditionMutex) { - RMW_SET_ERROR_MSG("waitset mutex is null"); + RMW_SET_ERROR_MSG("wait_set mutex is null"); return RMW_RET_ERROR; } - if (waitset->data) { - if (waitset_info) { + if (wait_set->data) { + if (wait_set_info) { RMW_TRY_DESTRUCTOR( - waitset_info->~CustomWaitsetInfo(), waitset_info, result = RMW_RET_ERROR) + wait_set_info->~CustomWaitsetInfo(), wait_set_info, result = RMW_RET_ERROR) } - rmw_free(waitset->data); + rmw_free(wait_set->data); } - rmw_waitset_free(waitset); + rmw_wait_set_free(wait_set); return result; } } // extern "C" From f7a5c41483f504dd1e45747ef87537ba4aee9516 Mon Sep 17 00:00:00 2001 From: Mikael Arguedas Date: Thu, 23 Nov 2017 08:51:01 -0800 Subject: [PATCH 3/5] [cpplint] header guard --- rmw_fastrtps_cpp/src/types/custom_wait_set_info.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rmw_fastrtps_cpp/src/types/custom_wait_set_info.hpp b/rmw_fastrtps_cpp/src/types/custom_wait_set_info.hpp index 36d488b5e..0d53fd27d 100644 --- a/rmw_fastrtps_cpp/src/types/custom_wait_set_info.hpp +++ b/rmw_fastrtps_cpp/src/types/custom_wait_set_info.hpp @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef TYPES__CUSTOM_WAITSET_INFO_HPP_ -#define TYPES__CUSTOM_WAITSET_INFO_HPP_ +#ifndef TYPES__CUSTOM_WAIT_SET_INFO_HPP_ +#define TYPES__CUSTOM_WAIT_SET_INFO_HPP_ #include #include @@ -24,4 +24,4 @@ typedef struct CustomWaitsetInfo std::mutex condition_mutex; } CustomWaitsetInfo; -#endif // TYPES__CUSTOM_WAITSET_INFO_HPP_ +#endif // TYPES__CUSTOM_WAIT_SET_INFO_HPP_ From 6ec1aeaf5d4ceec3af91857e245730cb8b11f684 Mon Sep 17 00:00:00 2001 From: Mikael Arguedas Date: Fri, 24 Nov 2017 15:16:50 -0800 Subject: [PATCH 4/5] use wait set in doc --- rmw_fastrtps_cpp/src/rmw_wait.cpp | 6 +++--- rmw_fastrtps_cpp/src/rmw_wait_set.cpp | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rmw_fastrtps_cpp/src/rmw_wait.cpp b/rmw_fastrtps_cpp/src/rmw_wait.cpp index c4056cc97..047ca15de 100644 --- a/rmw_fastrtps_cpp/src/rmw_wait.cpp +++ b/rmw_fastrtps_cpp/src/rmw_wait.cpp @@ -86,7 +86,7 @@ rmw_wait( const rmw_time_t * wait_timeout) { if (!wait_set) { - RMW_SET_ERROR_MSG("Waitset handle is null"); + RMW_SET_ERROR_MSG("wait set handle is null"); return RMW_RET_ERROR; } CustomWaitsetInfo * wait_set_info = static_cast(wait_set->data); @@ -97,11 +97,11 @@ rmw_wait( std::mutex * conditionMutex = &wait_set_info->condition_mutex; std::condition_variable * conditionVariable = &wait_set_info->condition; if (!conditionMutex) { - RMW_SET_ERROR_MSG("Mutex for wait_set was null"); + RMW_SET_ERROR_MSG("Mutex for wait set was null"); return RMW_RET_ERROR; } if (!conditionVariable) { - RMW_SET_ERROR_MSG("Condition variable for wait_set was null"); + RMW_SET_ERROR_MSG("Condition variable for wait set was null"); return RMW_RET_ERROR; } diff --git a/rmw_fastrtps_cpp/src/rmw_wait_set.cpp b/rmw_fastrtps_cpp/src/rmw_wait_set.cpp index 205ba355b..806160337 100644 --- a/rmw_fastrtps_cpp/src/rmw_wait_set.cpp +++ b/rmw_fastrtps_cpp/src/rmw_wait_set.cpp @@ -31,7 +31,7 @@ rmw_create_wait_set(size_t max_conditions) // From here onward, error results in unrolling in the goto fail block. if (!wait_set) { - RMW_SET_ERROR_MSG("failed to allocate wait_set"); + RMW_SET_ERROR_MSG("failed to allocate wait set"); goto fail; } wait_set->implementation_identifier = eprosima_fastrtps_identifier; @@ -40,7 +40,7 @@ rmw_create_wait_set(size_t max_conditions) wait_set_info = static_cast(wait_set->data); RMW_TRY_PLACEMENT_NEW(wait_set_info, wait_set_info, goto fail, CustomWaitsetInfo, ) if (!wait_set_info) { - RMW_SET_ERROR_MSG("failed to construct wait_set info struct"); + RMW_SET_ERROR_MSG("failed to construct wait set info struct"); goto fail; } @@ -62,7 +62,7 @@ rmw_ret_t rmw_destroy_wait_set(rmw_wait_set_t * wait_set) { if (!wait_set) { - RMW_SET_ERROR_MSG("wait_set handle is null"); + RMW_SET_ERROR_MSG("wait set handle is null"); return RMW_RET_ERROR; } RMW_CHECK_TYPE_IDENTIFIERS_MATCH( @@ -73,12 +73,12 @@ rmw_destroy_wait_set(rmw_wait_set_t * wait_set) auto result = RMW_RET_OK; auto wait_set_info = static_cast(wait_set->data); if (!wait_set_info) { - RMW_SET_ERROR_MSG("wait_set info is null"); + RMW_SET_ERROR_MSG("wait set info is null"); return RMW_RET_ERROR; } std::mutex * conditionMutex = &wait_set_info->condition_mutex; if (!conditionMutex) { - RMW_SET_ERROR_MSG("wait_set mutex is null"); + RMW_SET_ERROR_MSG("wait set mutex is null"); return RMW_RET_ERROR; } From 8d3128d48621e944cb4903ad06f9f62cf643c0b9 Mon Sep 17 00:00:00 2001 From: dhood Date: Mon, 27 Nov 2017 08:00:16 -0800 Subject: [PATCH 5/5] 'wait_set handle' -> 'wait set handle' for error msg string --- rmw_fastrtps_cpp/src/rmw_wait_set.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rmw_fastrtps_cpp/src/rmw_wait_set.cpp b/rmw_fastrtps_cpp/src/rmw_wait_set.cpp index 806160337..e9bf61e57 100644 --- a/rmw_fastrtps_cpp/src/rmw_wait_set.cpp +++ b/rmw_fastrtps_cpp/src/rmw_wait_set.cpp @@ -66,7 +66,7 @@ rmw_destroy_wait_set(rmw_wait_set_t * wait_set) return RMW_RET_ERROR; } RMW_CHECK_TYPE_IDENTIFIERS_MATCH( - wait_set handle, + wait set handle, wait_set->implementation_identifier, eprosima_fastrtps_identifier, return RMW_RET_ERROR)