Skip to content

Commit 44b926a

Browse files
authored
Rollup merge of rust-lang#38010 - frewsxcv:lock-creations, r=GuillaumeGomez
Document how lock 'guard' structures are created.
2 parents f9f92e1 + 6075af4 commit 44b926a

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/libstd/sync/mutex.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,14 @@ unsafe impl<T: ?Sized + Send> Sync for Mutex<T> { }
133133
/// dropped (falls out of scope), the lock will be unlocked.
134134
///
135135
/// The data protected by the mutex can be access through this guard via its
136-
/// `Deref` and `DerefMut` implementations
136+
/// `Deref` and `DerefMut` implementations.
137+
///
138+
/// This structure is created by the [`lock()`] and [`try_lock()`] methods on
139+
/// [`Mutex`].
140+
///
141+
/// [`lock()`]: struct.Mutex.html#method.lock
142+
/// [`try_lock()`]: struct.Mutex.html#method.try_lock
143+
/// [`Mutex`]: struct.Mutex.html
137144
#[must_use]
138145
#[stable(feature = "rust1", since = "1.0.0")]
139146
pub struct MutexGuard<'a, T: ?Sized + 'a> {

src/libstd/sync/rwlock.rs

+14
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ unsafe impl<T: ?Sized + Send + Sync> Sync for RwLock<T> {}
7777

7878
/// RAII structure used to release the shared read access of a lock when
7979
/// dropped.
80+
///
81+
/// This structure is created by the [`read()`] and [`try_read()`] methods on
82+
/// [`RwLock`].
83+
///
84+
/// [`read()`]: struct.RwLock.html#method.read
85+
/// [`try_read()`]: struct.RwLock.html#method.try_read
86+
/// [`RwLock`]: struct.RwLock.html
8087
#[must_use]
8188
#[stable(feature = "rust1", since = "1.0.0")]
8289
pub struct RwLockReadGuard<'a, T: ?Sized + 'a> {
@@ -88,6 +95,13 @@ impl<'a, T: ?Sized> !marker::Send for RwLockReadGuard<'a, T> {}
8895

8996
/// RAII structure used to release the exclusive write access of a lock when
9097
/// dropped.
98+
///
99+
/// This structure is created by the [`write()`] and [`try_write()`] methods
100+
/// on [`RwLock`].
101+
///
102+
/// [`write()`]: struct.RwLock.html#method.write
103+
/// [`try_write()`]: struct.RwLock.html#method.try_write
104+
/// [`RwLock`]: struct.RwLock.html
91105
#[must_use]
92106
#[stable(feature = "rust1", since = "1.0.0")]
93107
pub struct RwLockWriteGuard<'a, T: ?Sized + 'a> {

0 commit comments

Comments
 (0)