Skip to content

Commit

Permalink
Merge pull request Amanieu#414 from waywardmonkeys/markdown-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanieu authored Oct 24, 2023
2 parents c35fcd0 + 3b60799 commit 7337631
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 36 deletions.
4 changes: 2 additions & 2 deletions core/src/parking_lot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ pub mod deadlock {
pub(super) use super::deadlock_impl::DeadlockData;

/// Acquire a resource identified by key in the deadlock detector
/// Noop if deadlock_detection feature isn't enabled.
/// Noop if `deadlock_detection` feature isn't enabled.
///
/// # Safety
///
Expand All @@ -1115,7 +1115,7 @@ pub mod deadlock {
}

/// Release a resource identified by key in the deadlock detector.
/// Noop if deadlock_detection feature isn't enabled.
/// Noop if `deadlock_detection` feature isn't enabled.
///
/// # Panics
///
Expand Down
4 changes: 2 additions & 2 deletions core/src/thread_parker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub trait ThreadParkerT {
unsafe fn prepare_park(&self);

/// Checks if the park timed out. This should be called while holding the
/// queue lock after park_until has returned false.
/// queue lock after `park_until` has returned false.
unsafe fn timed_out(&self) -> bool;

/// Parks the thread until it is unparked. This should be called after it has
Expand All @@ -33,7 +33,7 @@ pub trait ThreadParkerT {
unsafe fn park_until(&self, timeout: Instant) -> bool;

/// Locks the parker to prevent the target thread from exiting. This is
/// necessary to ensure that thread-local ThreadData objects remain valid.
/// necessary to ensure that thread-local `ThreadData` objects remain valid.
/// This should be called while holding the queue lock.
unsafe fn unpark_lock(&self) -> Self::UnparkHandle;
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/thread_parker/windows/bindings.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Manual bindings to the win32 API to avoid dependencies on windows-sys or winapi
//! as these bindings will **never** change and parking_lot_core is a foundational
//! as these bindings will **never** change and `parking_lot_core` is a foundational
//! dependency for the Rust ecosystem, so the dependencies used by it have an
//! outsize affect

Expand Down
2 changes: 1 addition & 1 deletion core/src/word_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub struct WordLock {
}

impl WordLock {
/// Returns a new, unlocked, WordLock.
/// Returns a new, unlocked, `WordLock`.
pub const fn new() -> Self {
WordLock {
state: AtomicUsize::new(0),
Expand Down
4 changes: 2 additions & 2 deletions lock_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.

//! This library provides type-safe and fully-featured `Mutex` and `RwLock`
//! This library provides type-safe and fully-featured [`Mutex`] and [`RwLock`]
//! types which wrap a simple raw mutex or rwlock type. This has several
//! benefits: not only does it eliminate a large portion of the work in
//! implementing custom lock types, it also allows users to write code which is
Expand All @@ -20,7 +20,7 @@
//! your mutex guard as a type alias for `lock_api::MutexGuard`.
//! See the [example](#example) below for details.
//!
//! This process is similar for RwLocks, except that two guards need to be
//! This process is similar for [`RwLock`]s, except that two guards need to be
//! exported instead of one. (Or 3 guards if your type supports upgradable read
//! locks, see [extension traits](#extension-traits) below for details)
//!
Expand Down
16 changes: 6 additions & 10 deletions lock_api/src/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ pub unsafe trait RawMutex {
/// This method may only be called if the mutex is held in the current context, i.e. it must
/// be paired with a successful call to [`lock`], [`try_lock`], [`try_lock_for`] or [`try_lock_until`].
///
/// [`lock`]: #tymethod.lock
/// [`try_lock`]: #tymethod.try_lock
/// [`try_lock_for`]: trait.RawMutexTimed.html#tymethod.try_lock_for
/// [`try_lock_until`]: trait.RawMutexTimed.html#tymethod.try_lock_until
/// [`lock`]: RawMutex::lock
/// [`try_lock`]: RawMutex::try_lock
/// [`try_lock_for`]: RawMutexTimed::try_lock_for
/// [`try_lock_until`]: RawMutexTimed::try_lock_until
unsafe fn unlock(&self);

/// Checks whether the mutex is currently locked.
Expand Down Expand Up @@ -90,9 +90,7 @@ pub unsafe trait RawMutexFair: RawMutex {
/// # Safety
///
/// This method may only be called if the mutex is held in the current context, see
/// the documentation of [`unlock`].
///
/// [`unlock`]: trait.RawMutex.html#tymethod.unlock
/// the documentation of [`unlock`](RawMutex::unlock).
unsafe fn unlock_fair(&self);

/// Temporarily yields the mutex to a waiting thread if there is one.
Expand All @@ -104,9 +102,7 @@ pub unsafe trait RawMutexFair: RawMutex {
/// # Safety
///
/// This method may only be called if the mutex is held in the current context, see
/// the documentation of [`unlock`].
///
/// [`unlock`]: trait.RawMutex.html#tymethod.unlock
/// the documentation of [`unlock`](RawMutex::unlock).
unsafe fn bump(&self) {
self.unlock_fair();
self.lock();
Expand Down
5 changes: 1 addition & 4 deletions lock_api/src/remutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ pub unsafe trait GetThreadId {
/// mutex can successfully acquire a lock multiple times in the same thread.
/// Only use this when you know you want a raw mutex that can be locked
/// reentrantly; you probably want [`ReentrantMutex`] instead.
///
/// [`RawMutex`]: trait.RawMutex.html
/// [`ReentrantMutex`]: struct.ReentrantMutex.html
pub struct RawReentrantMutex<R, G> {
owner: AtomicUsize,
lock_count: Cell<usize>,
Expand Down Expand Up @@ -214,7 +211,7 @@ impl<R: RawMutexTimed, G: GetThreadId> RawReentrantMutex<R, G> {
/// - `ReentrantMutexGuard` does not give mutable references to the locked data.
/// Use a `RefCell` if you need this.
///
/// See [`Mutex`](struct.Mutex.html) for more details about the underlying mutex
/// See [`Mutex`](crate::Mutex) for more details about the underlying mutex
/// primitive.
pub struct ReentrantMutex<R, G, T: ?Sized> {
raw: RawReentrantMutex<R, G>,
Expand Down
22 changes: 11 additions & 11 deletions lock_api/src/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub unsafe trait RawRwLock {
}
}

/// Additional methods for RwLocks which support fair unlocking.
/// Additional methods for `RwLock`s which support fair unlocking.
///
/// Fair unlocking means that a lock is handed directly over to the next waiting
/// thread if there is one, without giving other threads the opportunity to
Expand Down Expand Up @@ -148,7 +148,7 @@ pub unsafe trait RawRwLockFair: RawRwLock {
}
}

/// Additional methods for RwLocks which support atomically downgrading an
/// Additional methods for `RwLock`s which support atomically downgrading an
/// exclusive lock to a shared lock.
pub unsafe trait RawRwLockDowngrade: RawRwLock {
/// Atomically downgrades an exclusive lock into a shared lock without
Expand All @@ -160,7 +160,7 @@ pub unsafe trait RawRwLockDowngrade: RawRwLock {
unsafe fn downgrade(&self);
}

/// Additional methods for RwLocks which support locking with timeouts.
/// Additional methods for `RwLock`s which support locking with timeouts.
///
/// The `Duration` and `Instant` types are specified as associated types so that
/// this trait is usable even in `no_std` environments.
Expand All @@ -184,7 +184,7 @@ pub unsafe trait RawRwLockTimed: RawRwLock {
fn try_lock_exclusive_until(&self, timeout: Self::Instant) -> bool;
}

/// Additional methods for RwLocks which support recursive read locks.
/// Additional methods for `RwLock`s which support recursive read locks.
///
/// These are guaranteed to succeed without blocking if
/// another read lock is held at the time of the call. This allows a thread
Expand All @@ -199,7 +199,7 @@ pub unsafe trait RawRwLockRecursive: RawRwLock {
fn try_lock_shared_recursive(&self) -> bool;
}

/// Additional methods for RwLocks which support recursive read locks and timeouts.
/// Additional methods for `RwLock`s which support recursive read locks and timeouts.
pub unsafe trait RawRwLockRecursiveTimed: RawRwLockRecursive + RawRwLockTimed {
/// Attempts to acquire a shared lock until a timeout is reached, without
/// deadlocking in case of a recursive lock.
Expand All @@ -210,7 +210,7 @@ pub unsafe trait RawRwLockRecursiveTimed: RawRwLockRecursive + RawRwLockTimed {
fn try_lock_shared_recursive_until(&self, timeout: Self::Instant) -> bool;
}

/// Additional methods for RwLocks which support atomically upgrading a shared
/// Additional methods for `RwLock`s which support atomically upgrading a shared
/// lock to an exclusive lock.
///
/// This requires acquiring a special "upgradable read lock" instead of a
Expand Down Expand Up @@ -246,7 +246,7 @@ pub unsafe trait RawRwLockUpgrade: RawRwLock {
unsafe fn try_upgrade(&self) -> bool;
}

/// Additional methods for RwLocks which support upgradable locks and fair
/// Additional methods for `RwLock`s which support upgradable locks and fair
/// unlocking.
pub unsafe trait RawRwLockUpgradeFair: RawRwLockUpgrade + RawRwLockFair {
/// Releases an upgradable lock using a fair unlock protocol.
Expand All @@ -271,7 +271,7 @@ pub unsafe trait RawRwLockUpgradeFair: RawRwLockUpgrade + RawRwLockFair {
}
}

/// Additional methods for RwLocks which support upgradable locks and lock
/// Additional methods for `RwLock`s which support upgradable locks and lock
/// downgrading.
pub unsafe trait RawRwLockUpgradeDowngrade: RawRwLockUpgrade + RawRwLockDowngrade {
/// Downgrades an upgradable lock to a shared lock.
Expand All @@ -289,7 +289,7 @@ pub unsafe trait RawRwLockUpgradeDowngrade: RawRwLockUpgrade + RawRwLockDowngrad
unsafe fn downgrade_to_upgradable(&self);
}

/// Additional methods for RwLocks which support upgradable locks and locking
/// Additional methods for `RwLock`s which support upgradable locks and locking
/// with timeouts.
pub unsafe trait RawRwLockUpgradeTimed: RawRwLockUpgrade + RawRwLockTimed {
/// Attempts to acquire an upgradable lock until a timeout is reached.
Expand Down Expand Up @@ -417,7 +417,7 @@ impl<R: RawRwLock, T: ?Sized> RwLock<R, T> {
///
/// This function does not increment the read count of the lock. Calling this function when a
/// guard has already been produced is undefined behaviour unless the guard was forgotten
/// with `mem::forget`.`
/// with `mem::forget`.
#[inline]
pub unsafe fn make_read_guard_unchecked(&self) -> RwLockReadGuard<'_, R, T> {
RwLockReadGuard {
Expand Down Expand Up @@ -1016,7 +1016,7 @@ impl<R: RawRwLockUpgrade, T: ?Sized> RwLock<R, T> {
///
/// This function does not increment the read count of the lock. Calling this function when a
/// guard has already been produced is undefined behaviour unless the guard was forgotten
/// with `mem::forget`.`
/// with `mem::forget`.
#[inline]
pub unsafe fn make_upgradable_guard_unchecked(&self) -> RwLockUpgradableReadGuard<'_, R, T> {
RwLockUpgradableReadGuard {
Expand Down
4 changes: 2 additions & 2 deletions src/raw_rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -923,8 +923,8 @@ impl RawRwLock {
self.lock_upgradable();
}

/// Common code for waking up parked threads after releasing WRITER_BIT or
/// UPGRADABLE_BIT.
/// Common code for waking up parked threads after releasing `WRITER_BIT` or
/// `UPGRADABLE_BIT`.
///
/// # Safety
///
Expand Down
2 changes: 1 addition & 1 deletion src/remutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ unsafe impl GetThreadId for RawThreadId {
/// - `ReentrantMutexGuard` does not give mutable references to the locked data.
/// Use a `RefCell` if you need this.
///
/// See [`Mutex`](type.Mutex.html) for more details about the underlying mutex
/// See [`Mutex`](crate::Mutex) for more details about the underlying mutex
/// primitive.
pub type ReentrantMutex<T> = lock_api::ReentrantMutex<RawMutex, RawThreadId, T>;

Expand Down

0 comments on commit 7337631

Please sign in to comment.