From 9c3d987f071f02494c33ff5973632446d523ec5f Mon Sep 17 00:00:00 2001 From: Luca Della Vedova Date: Fri, 4 Aug 2023 11:26:52 +0800 Subject: [PATCH] Add comparison function for times, use reference to clock Signed-off-by: Luca Della Vedova --- rclrs/src/clock.rs | 2 +- rclrs/src/time.rs | 48 +++++++++++++++++++++++++++++++++++++--------- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/rclrs/src/clock.rs b/rclrs/src/clock.rs index ea4ac4e7..3668516d 100644 --- a/rclrs/src/clock.rs +++ b/rclrs/src/clock.rs @@ -101,7 +101,7 @@ impl Clock { } Time { nsec: time_point, - clock_type: self._type, + clock: Arc::downgrade(&self._rcl_clock), } } diff --git a/rclrs/src/time.rs b/rclrs/src/time.rs index d5427470..14e1704d 100644 --- a/rclrs/src/time.rs +++ b/rclrs/src/time.rs @@ -1,20 +1,50 @@ -use crate::clock::ClockType; use crate::rcl_bindings::*; +use std::sync::{Mutex, Weak}; /// Struct that represents time. #[derive(Debug)] pub struct Time { /// Timestamp in nanoseconds. pub nsec: i64, - /// Clock type. - pub clock_type: ClockType, + /// Weak reference to the clock that generated this time + pub clock: Weak>, } -impl From