use iceoryx2_bb_elementary_traits::zero_copy_send::ZeroCopySend;
#[cfg(feature = "std")]
use std::sync::MutexGuard;
#[cfg(not(feature = "std"))]
use iceoryx2_pal_concurrency_sync::spin_lock::SpinLockGuard as MutexGuard;
#[derive(Debug, Default, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[repr(transparent)]
pub struct LifetimeTracker(internal::LifetimeTracker);
impl core::ops::Deref for LifetimeTracker {
type Target = internal::LifetimeTracker;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl core::ops::DerefMut for LifetimeTracker {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl LifetimeTracker {
pub fn new() -> Self {
Self(internal::LifetimeTracker::new())
}
pub fn new_with_value(value: usize) -> Self {
Self(internal::LifetimeTracker::new_with_value(value))
}
pub fn start_tracking() -> MutexGuard<'static, internal::LifetimeTrackingState> {
internal::LifetimeTracker::start_tracking()
}
}
unsafe impl ZeroCopySend for LifetimeTracker {}
mod internal {
pub use iceoryx2_pal_testing::lifetime_tracker::LifetimeTracker;
pub use iceoryx2_pal_testing::lifetime_tracker::LifetimeTrackingState;
}