summaryrefslogtreecommitdiff
path: root/src/rwlock
diff options
context:
space:
mode:
Diffstat (limited to 'src/rwlock')
-rw-r--r--src/rwlock/read_lock.rs12
-rw-r--r--src/rwlock/rwlock.rs2
-rw-r--r--src/rwlock/write_lock.rs10
3 files changed, 12 insertions, 12 deletions
diff --git a/src/rwlock/read_lock.rs b/src/rwlock/read_lock.rs
index a8bb9be..011bd8c 100644
--- a/src/rwlock/read_lock.rs
+++ b/src/rwlock/read_lock.rs
@@ -28,8 +28,8 @@ impl<T: ?Sized + Debug, R: RawRwLock> Debug for ReadLock<T, R> {
}
}
-impl<T, R> From<RwLock<T, R>> for ReadLock<T, R> {
- fn from(value: RwLock<T, R>) -> Self {
+impl<'l, T, R> From<&'l RwLock<T, R>> for ReadLock<'l, T, R> {
+ fn from(value: &'l RwLock<T, R>) -> Self {
Self::new(value)
}
}
@@ -40,7 +40,7 @@ impl<T: ?Sized, R> AsRef<RwLock<T, R>> for ReadLock<T, R> {
}
}
-impl<T, R> ReadLock<T, R> {
+impl<'l, T, R> ReadLock<'l, T, R> {
/// Creates a new `ReadLock` which accesses the given [`RwLock`]
///
/// # Examples
@@ -52,12 +52,12 @@ impl<T, R> ReadLock<T, R> {
/// let read_lock = ReadLock::new(&lock);
/// ```
#[must_use]
- pub const fn new(rwlock: RwLock<T, R>) -> Self {
+ pub const fn new(rwlock: &'l RwLock<T, R>) -> Self {
Self(rwlock)
}
}
-impl<T: ?Sized, R: RawRwLock> ReadLock<T, R> {
+impl<'l, T: ?Sized, R: RawRwLock> ReadLock<'l, T, R> {
/// Locks the underlying [`RwLock`] with shared read access, blocking the
/// current thread until it can be acquired.
pub fn lock<'s, 'key: 's, Key: Keyable + 'key>(
@@ -82,7 +82,7 @@ impl<T: ?Sized, R: RawRwLock> ReadLock<T, R> {
self.0.try_read_no_key()
}
- /// Immediately drops the guard, and consequentlyreleases the shared lock
+ /// Immediately drops the guard, and consequently releases the shared lock
/// on the underlying [`RwLock`].
pub fn unlock<'key, Key: Keyable + 'key>(guard: RwLockReadGuard<'_, 'key, T, Key, R>) -> Key {
RwLock::unlock_read(guard)
diff --git a/src/rwlock/rwlock.rs b/src/rwlock/rwlock.rs
index d16befe..7070b0e 100644
--- a/src/rwlock/rwlock.rs
+++ b/src/rwlock/rwlock.rs
@@ -254,7 +254,7 @@ impl<T: ?Sized, R: RawRwLock> RwLock<T, R> {
/// Attempts to lock this `RwLock` with exclusive write access.
///
/// This function does not block. If the lock could not be acquired at this
- /// time, then `None` is returned. Otherwise an RAII guard is returned
+ /// time, then `None` is returned. Otherwise, an RAII guard is returned
/// which will release the lock when it is dropped.
///
/// This function does not provide any guarantees with respect to the
diff --git a/src/rwlock/write_lock.rs b/src/rwlock/write_lock.rs
index a344125..1f7112a 100644
--- a/src/rwlock/write_lock.rs
+++ b/src/rwlock/write_lock.rs
@@ -21,15 +21,15 @@ impl<T: ?Sized + Debug, R: RawRwLock> Debug for WriteLock<T, R> {
}
}
- f.debug_struct("ReadLock")
+ f.debug_struct("WriteLock")
.field("data", &LockedPlaceholder)
.finish()
}
}
}
-impl<T, R> From<RwLock<T, R>> for WriteLock<T, R> {
- fn from(value: RwLock<T, R>) -> Self {
+impl<'l, T, R> From<&'l RwLock<T, R>> for WriteLock<'l, T, R> {
+ fn from(value: &'l RwLock<T, R>) -> Self {
Self::new(value)
}
}
@@ -40,7 +40,7 @@ impl<T: ?Sized, R> AsRef<RwLock<T, R>> for WriteLock<T, R> {
}
}
-impl<T, R> WriteLock<T, R> {
+impl<'l, T, R> WriteLock<'l, T, R> {
/// Creates a new `WriteLock` which accesses the given [`RwLock`]
///
/// # Examples
@@ -52,7 +52,7 @@ impl<T, R> WriteLock<T, R> {
/// let write_lock = WriteLock::new(&lock);
/// ```
#[must_use]
- pub const fn new(rwlock: RwLock<T, R>) -> Self {
+ pub const fn new(rwlock: &'l RwLock<T, R>) -> Self {
Self(rwlock)
}
}