Skip to content

Commit

Permalink
Attempt to workaround visibility limitations
Browse files Browse the repository at this point in the history
  • Loading branch information
bertptrs committed Mar 1, 2025
1 parent d1a6b93 commit 5d50de6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
5 changes: 3 additions & 2 deletions src/lockapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use lock_api::RawRwLockUpgradeDowngrade;
use lock_api::RawRwLockUpgradeFair;
use lock_api::RawRwLockUpgradeTimed;

use crate::util::PrivateTraced;
use crate::util::private::Traced;
use crate::LazyMutexId;
use crate::MutexId;

Expand Down Expand Up @@ -88,7 +88,8 @@ impl<T> TracingWrapper<T> {
}
}

impl<T> PrivateTraced for TracingWrapper<T> {
impl<T> Traced for TracingWrapper<T> {
#[allow(private_interfaces)]
fn get_id(&self) -> &MutexId {
&self.id
}
Expand Down
14 changes: 9 additions & 5 deletions src/stdsync/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::sync::TryLockResult;
use std::sync::WaitTimeoutResult;
use std::time::Duration;

use crate::util::PrivateTraced;
use crate::util::private::Traced;
use crate::BorrowedMutex;
use crate::LazyMutexId;

Expand Down Expand Up @@ -128,7 +128,8 @@ impl<T> Mutex<T> {
}
}

impl<T> PrivateTraced for Mutex<T> {
impl<T> Traced for Mutex<T> {
#[allow(private_interfaces)]
fn get_id(&self) -> &crate::MutexId {
&self.id
}
Expand Down Expand Up @@ -382,7 +383,8 @@ impl<T> RwLock<T> {
}
}

impl<T> PrivateTraced for RwLock<T> {
impl<T> Traced for RwLock<T> {
#[allow(private_interfaces)]
fn get_id(&self) -> &crate::MutexId {
&self.id
}
Expand Down Expand Up @@ -468,7 +470,8 @@ impl Once {
}
}

impl PrivateTraced for Once {
impl Traced for Once {
#[allow(private_interfaces)]
fn get_id(&self) -> &crate::MutexId {
&self.mutex_id
}
Expand Down Expand Up @@ -572,7 +575,8 @@ impl<T> OnceLock<T> {
}
}

impl<T> PrivateTraced for OnceLock<T> {
impl<T> Traced for OnceLock<T> {
#[allow(private_interfaces)]
fn get_id(&self) -> &crate::MutexId {
&self.id
}
Expand Down
24 changes: 13 additions & 11 deletions src/util.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use crate::MutexId;

/// Reset the dependencies for the given entity.
///
/// # Performance
Expand Down Expand Up @@ -45,15 +43,19 @@ pub unsafe fn reset_dependencies<T: Traced>(traced: &T) {
///
/// This trait is a public marker trait and is automatically implemented fore all types that
/// implement the internal dependency tracking features.
#[allow(private_bounds)]
pub trait Traced: PrivateTraced {}
pub trait Traced: private::Traced {}

impl<T: PrivateTraced> Traced for T {}
pub(crate) mod private {
use crate::MutexId;

/// Private implementation of the traced marker.
///
/// This trait is private (and seals the outer trait) to avoid exposing the MutexId type.
pub(crate) trait PrivateTraced {
/// Get the mutex id associated with this traced item.
fn get_id(&self) -> &MutexId;
impl<T: Traced> super::Traced for T {}

/// Private implementation of the traced marker.
///
/// This trait is private (and seals the outer trait) to avoid exposing the MutexId type.
pub trait Traced {
/// Get the mutex id associated with this traced item.
#[allow(private_interfaces)]
fn get_id(&self) -> &MutexId;
}
}

0 comments on commit 5d50de6

Please sign in to comment.