Skip to content

Commit

Permalink
Merge pull request #372 from luca-della-vedova/fix/node_drop_order
Browse files Browse the repository at this point in the history
Move rcl structs to end of Node declaration
  • Loading branch information
jhdcs authored Mar 18, 2024
2 parents 62fea75 + 1b75a23 commit 5159d71
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions rclrs/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Mutex<rcl_node_t>>,
pub(crate) rcl_context_mtx: Arc<Mutex<rcl_context_t>>,
pub(crate) clients_mtx: Mutex<Vec<Weak<dyn ClientBase>>>,
pub(crate) guard_conditions_mtx: Mutex<Vec<Weak<GuardCondition>>>,
pub(crate) services_mtx: Mutex<Vec<Weak<dyn ServiceBase>>>,
pub(crate) subscriptions_mtx: Mutex<Vec<Weak<dyn SubscriptionBase>>>,
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<Mutex<rcl_node_t>>,
pub(crate) rcl_context_mtx: Arc<Mutex<rcl_context_t>>,
}

impl Eq for Node {}
Expand Down

0 comments on commit 5159d71

Please sign in to comment.