mirror of
https://github.com/bertptrs/tracing-mutex.git
synced 2025-12-25 20:50:32 +01:00
Make stdsync wrappers const-constructible
This commit is contained in:
@@ -42,7 +42,6 @@ pub mod tracing {
|
|||||||
|
|
||||||
use crate::BorrowedMutex;
|
use crate::BorrowedMutex;
|
||||||
use crate::LazyMutexId;
|
use crate::LazyMutexId;
|
||||||
use crate::MutexId;
|
|
||||||
|
|
||||||
/// Wrapper for [`std::sync::Mutex`].
|
/// Wrapper for [`std::sync::Mutex`].
|
||||||
///
|
///
|
||||||
@@ -51,7 +50,7 @@ pub mod tracing {
|
|||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct Mutex<T> {
|
pub struct Mutex<T> {
|
||||||
inner: sync::Mutex<T>,
|
inner: sync::Mutex<T>,
|
||||||
id: MutexId,
|
id: LazyMutexId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wrapper for [`std::sync::MutexGuard`].
|
/// Wrapper for [`std::sync::MutexGuard`].
|
||||||
@@ -89,10 +88,10 @@ pub mod tracing {
|
|||||||
|
|
||||||
impl<T> Mutex<T> {
|
impl<T> Mutex<T> {
|
||||||
/// Create a new tracing mutex with the provided value.
|
/// Create a new tracing mutex with the provided value.
|
||||||
pub fn new(t: T) -> Self {
|
pub const fn new(t: T) -> Self {
|
||||||
Self {
|
Self {
|
||||||
inner: sync::Mutex::new(t),
|
inner: sync::Mutex::new(t),
|
||||||
id: MutexId::new(),
|
id: LazyMutexId::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,8 +219,8 @@ pub mod tracing {
|
|||||||
|
|
||||||
impl Condvar {
|
impl Condvar {
|
||||||
/// Creates a new condition variable which is ready to be waited on and notified.
|
/// Creates a new condition variable which is ready to be waited on and notified.
|
||||||
pub fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
Default::default()
|
Self(sync::Condvar::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wrapper for [`std::sync::Condvar::wait`].
|
/// Wrapper for [`std::sync::Condvar::wait`].
|
||||||
@@ -294,7 +293,7 @@ pub mod tracing {
|
|||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct RwLock<T> {
|
pub struct RwLock<T> {
|
||||||
inner: sync::RwLock<T>,
|
inner: sync::RwLock<T>,
|
||||||
id: MutexId,
|
id: LazyMutexId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Hybrid wrapper for both [`std::sync::RwLockReadGuard`] and [`std::sync::RwLockWriteGuard`].
|
/// Hybrid wrapper for both [`std::sync::RwLockReadGuard`] and [`std::sync::RwLockWriteGuard`].
|
||||||
@@ -312,10 +311,10 @@ pub mod tracing {
|
|||||||
pub type RwLockWriteGuard<'a, T> = TracingRwLockGuard<'a, sync::RwLockWriteGuard<'a, T>>;
|
pub type RwLockWriteGuard<'a, T> = TracingRwLockGuard<'a, sync::RwLockWriteGuard<'a, T>>;
|
||||||
|
|
||||||
impl<T> RwLock<T> {
|
impl<T> RwLock<T> {
|
||||||
pub fn new(t: T) -> Self {
|
pub const fn new(t: T) -> Self {
|
||||||
Self {
|
Self {
|
||||||
inner: sync::RwLock::new(t),
|
inner: sync::RwLock::new(t),
|
||||||
id: MutexId::new(),
|
id: LazyMutexId::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user