rclcpp
master
C++ ROS Client Library API
|
Go to the documentation of this file.
15 #ifndef RCLCPP__WAIT_SET_POLICIES__THREAD_SAFE_SYNCHRONIZATION_HPP_
16 #define RCLCPP__WAIT_SET_POLICIES__THREAD_SAFE_SYNCHRONIZATION_HPP_
40 namespace wait_set_policies
104 > add_subscription_function)
108 add_subscription_function(
std::move(subscription), mask);
118 > remove_subscription_function)
122 remove_subscription_function(
std::move(subscription), mask);
133 add_guard_condition_function(
std::move(guard_condition));
144 remove_guard_condition_function(
std::move(guard_condition));
188 remove_client_function(
std::move(client));
199 add_service_function(
std::move(service));
210 remove_service_function(
std::move(service));
220 > add_waitable_function)
235 remove_waitable_function(
std::move(waitable));
244 prune_deleted_entities_function();
248 template<
class WaitResultT>
282 rebuild_rcl_wait_set();
306 bool was_interrupted_by_this_class =
false;
307 bool any_user_guard_conditions_triggered =
false;
310 if (
nullptr != current) {
312 if (rcl_wait_set.
guard_conditions[index] == interrupt_guard_condition_ptr) {
314 was_interrupted_by_this_class =
true;
317 any_user_guard_conditions_triggered =
true;
322 if (!was_interrupted_by_this_class || any_user_guard_conditions_triggered) {
353 }
while (should_loop());
379 #endif // RCLCPP__WAIT_SET_POLICIES__THREAD_SAFE_SYNCHRONIZATION_HPP_
ThreadSafeSynchronization(rclcpp::Context::SharedPtr context)
Definition: thread_safe_synchronization.hpp:70
void sync_remove_subscription(std::shared_ptr< rclcpp::SubscriptionBase > &&subscription, const rclcpp::SubscriptionWaitSetMask &mask, std::function< void(std::shared_ptr< rclcpp::SubscriptionBase > &&, const rclcpp::SubscriptionWaitSetMask &) > remove_subscription_function)
Remove guard condition.
Definition: thread_safe_synchronization.hpp:113
~ThreadSafeSynchronization()=default
std::function< bool()> create_loop_predicate(std::chrono::nanoseconds time_to_wait_ns, std::chrono::steady_clock::time_point start)
Definition: synchronization_policy_common.hpp:36
@ Ready
Definition: wait_result_kind.hpp:26
WaitResultKind
Represents the various kinds of results from waiting on a wait set.
Definition: wait_result_kind.hpp:24
void sync_remove_waitable(std::shared_ptr< rclcpp::Waitable > &&waitable, std::function< void(std::shared_ptr< rclcpp::Waitable > &&)> remove_waitable_function)
Remove waitable.
Definition: thread_safe_synchronization.hpp:229
ReadMutex & get_read_mutex()
Return read mutex which can be used with standard constructs like std::lock_guard.
rclcpp::wait_set_policies::detail::WritePreferringReadWriteLock wprw_lock_
Definition: thread_safe_synchronization.hpp:373
Options used to determine what parts of a subscription get added to or removed from a wait set.
Definition: subscription_wait_set_mask.hpp:24
void sync_add_waitable(std::shared_ptr< rclcpp::Waitable > &&waitable, std::shared_ptr< void > &&associated_entity, std::function< void(std::shared_ptr< rclcpp::Waitable > &&, std::shared_ptr< void > &&) > add_waitable_function)
Add waitable.
Definition: thread_safe_synchronization.hpp:215
size_t size_of_guard_conditions
std::chrono::nanoseconds calculate_time_left_to_wait(std::chrono::nanoseconds original_time_to_wait_ns, std::chrono::steady_clock::time_point start)
Definition: synchronization_policy_common.hpp:51
WaitResultT sync_wait(std::chrono::nanoseconds time_to_wait_ns, std::function< void()> rebuild_rcl_wait_set, std::function< rcl_wait_set_t &()> get_rcl_wait_set, std::function< WaitResultT(WaitResultKind wait_result_kind)> create_wait_result)
Implements wait.
Definition: thread_safe_synchronization.hpp:250
void sync_wait_result_release()
Definition: thread_safe_synchronization.hpp:366
This header provides the get_node_base_interface() template function.
Definition: allocator_common.hpp:24
void sync_add_subscription(std::shared_ptr< rclcpp::SubscriptionBase > &&subscription, const rclcpp::SubscriptionWaitSetMask &mask, std::function< void(std::shared_ptr< rclcpp::SubscriptionBase > &&, const rclcpp::SubscriptionWaitSetMask &) > add_subscription_function)
Add subscription.
Definition: thread_safe_synchronization.hpp:99
WriteMutex & get_write_mutex()
Return write mutex which can be used with standard constructs like std::lock_guard.
void sync_add_client(std::shared_ptr< rclcpp::ClientBase > &&client, std::function< void(std::shared_ptr< rclcpp::ClientBase > &&)> add_client_function)
Add client.
Definition: thread_safe_synchronization.hpp:171
WaitSet policy that provides thread-safe synchronization for the wait set.
Definition: thread_safe_synchronization.hpp:67
const rcl_guard_condition_t ** guard_conditions
void sync_remove_service(std::shared_ptr< rclcpp::ServiceBase > &&service, std::function< void(std::shared_ptr< rclcpp::ServiceBase > &&)> remove_service_function)
Remove service.
Definition: thread_safe_synchronization.hpp:204
std::array< std::shared_ptr< rclcpp::GuardCondition >, 1 > extra_guard_conditions_
Definition: thread_safe_synchronization.hpp:372
void sync_add_guard_condition(std::shared_ptr< rclcpp::GuardCondition > &&guard_condition, std::function< void(std::shared_ptr< rclcpp::GuardCondition > &&)> add_guard_condition_function)
Add guard condition.
Definition: thread_safe_synchronization.hpp:127
@ Timeout
Definition: wait_result_kind.hpp:27
void sync_wait_result_acquire()
Definition: thread_safe_synchronization.hpp:360
void sync_remove_guard_condition(std::shared_ptr< rclcpp::GuardCondition > &&guard_condition, std::function< void(std::shared_ptr< rclcpp::GuardCondition > &&)> remove_guard_condition_function)
Remove guard condition.
Definition: thread_safe_synchronization.hpp:138
#define RCL_RET_WAIT_SET_EMPTY
void sync_remove_client(std::shared_ptr< rclcpp::ClientBase > &&client, std::function< void(std::shared_ptr< rclcpp::ClientBase > &&)> remove_client_function)
Remove client.
Definition: thread_safe_synchronization.hpp:182
void sync_remove_timer(std::shared_ptr< rclcpp::TimerBase > &&timer, std::function< void(std::shared_ptr< rclcpp::TimerBase > &&)> remove_timer_function)
Remove timer.
Definition: thread_safe_synchronization.hpp:160
Common structure for synchronization policies.
Definition: synchronization_policy_common.hpp:29
const std::array< std::shared_ptr< rclcpp::GuardCondition >, 1 > & get_extra_guard_conditions()
Return any "extra" guard conditions needed to implement the synchronization policy.
Definition: thread_safe_synchronization.hpp:82
void interrupt_waiting_wait_set()
Interrupt any waiting wait set.
Definition: thread_safe_synchronization.hpp:92
void sync_prune_deleted_entities(std::function< void()> prune_deleted_entities_function)
Prune deleted entities.
Definition: thread_safe_synchronization.hpp:240
@ Empty
Definition: wait_result_kind.hpp:28
void throw_from_rcl_error(rcl_ret_t ret, const std::string &prefix="", const rcl_error_state_t *error_state=nullptr, void(*reset_error)()=rcl_reset_error)
Throw a C++ std::exception which was created based on an rcl error.
void sync_add_service(std::shared_ptr< rclcpp::ServiceBase > &&service, std::function< void(std::shared_ptr< rclcpp::ServiceBase > &&)> add_service_function)
Add service.
Definition: thread_safe_synchronization.hpp:193
Writer-perferring read-write lock.
Definition: write_preferring_read_write_lock.hpp:170
void sync_add_timer(std::shared_ptr< rclcpp::TimerBase > &&timer, std::function< void(std::shared_ptr< rclcpp::TimerBase > &&)> add_timer_function)
Add timer.
Definition: thread_safe_synchronization.hpp:149
rcl_ret_t rcl_wait(rcl_wait_set_t *wait_set, int64_t timeout)