iceoryx2_bb_testing/
lifetime_tracker.rs1use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend;
14
15#[cfg(feature = "std")]
16use std::sync::MutexGuard;
17
18#[cfg(not(feature = "std"))]
19use iceoryx2_pal_concurrency_sync::spin_lock::SpinLockGuard as MutexGuard;
20
21#[derive(Debug, Default, Clone, PartialEq, Eq, PartialOrd, Ord)]
22#[repr(transparent)]
23pub struct LifetimeTracker(internal::LifetimeTracker);
24
25impl core::ops::Deref for LifetimeTracker {
26 type Target = internal::LifetimeTracker;
27
28 fn deref(&self) -> &Self::Target {
29 &self.0
30 }
31}
32
33impl core::ops::DerefMut for LifetimeTracker {
34 fn deref_mut(&mut self) -> &mut Self::Target {
35 &mut self.0
36 }
37}
38
39impl LifetimeTracker {
40 pub fn new() -> Self {
41 Self(internal::LifetimeTracker::new())
42 }
43
44 pub fn new_with_value(value: usize) -> Self {
45 Self(internal::LifetimeTracker::new_with_value(value))
46 }
47
48 pub fn start_tracking() -> MutexGuard<'static, internal::LifetimeTrackingState> {
49 internal::LifetimeTracker::start_tracking()
50 }
51}
52
53unsafe impl ZeroCopySend for LifetimeTracker {}
54
55mod internal {
56 pub use iceoryx2_pal_testing::lifetime_tracker::LifetimeTracker;
57 pub use iceoryx2_pal_testing::lifetime_tracker::LifetimeTrackingState;
58}