From 1b75a23a5769e74f0fddbbb9b088028a988c8288 Mon Sep 17 00:00:00 2001 From: Luca Della Vedova Date: Mon, 18 Mar 2024 12:22:17 +0800 Subject: [PATCH] Move rcl structs to end of Node declaration Signed-off-by: Luca Della Vedova --- rclrs/src/node.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rclrs/src/node.rs b/rclrs/src/node.rs index f1792c1e6..87702ab0f 100644 --- a/rclrs/src/node.rs +++ b/rclrs/src/node.rs @@ -65,14 +65,17 @@ unsafe impl Send for rcl_node_t {} /// [3]: crate::NodeBuilder::new /// [4]: crate::NodeBuilder::namespace pub struct Node { - pub(crate) rcl_node_mtx: Arc>, - pub(crate) rcl_context_mtx: Arc>, pub(crate) clients_mtx: Mutex>>, pub(crate) guard_conditions_mtx: Mutex>>, pub(crate) services_mtx: Mutex>>, pub(crate) subscriptions_mtx: Mutex>>, time_source: TimeSource, parameter: ParameterInterface, + // Note: it's important to have those last since `drop` will be called in order of declaration + // in the struct and both `TimeSource` and `ParameterInterface` contain subscriptions / + // services that will fail to be dropped if the context or node is destroyed first. + pub(crate) rcl_node_mtx: Arc>, + pub(crate) rcl_context_mtx: Arc>, } impl Eq for Node {}