Skip to content

Commit f747073

Browse files
Apply suggestions from code review
Co-authored-by: David Tolnay <[email protected]>
1 parent 1312d30 commit f747073

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/libstd/sync/mutex.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ use crate::sys_common::poison::{self, LockResult, TryLockError, TryLockResult};
108108
/// *guard += 1;
109109
/// ```
110110
///
111-
/// It is sometimes a good idea (or even necessary) to manually drop the mutex
112-
/// to unlock it as soon as possible. If you need the resource until the end of
111+
/// It is sometimes necessary to manually drop the mutex
112+
/// guard to unlock it as soon as possible. If you need the resource until the end of
113113
/// the scope, this is not needed.
114114
///
115115
/// ```
@@ -140,16 +140,16 @@ use crate::sys_common::poison::{self, LockResult, TryLockError, TryLockResult};
140140
/// // This is the result of some important and long-ish work.
141141
/// let result = data.iter().fold(0, |acc, x| acc + x * 2);
142142
/// data.push(result);
143-
/// // We drop the `data` explicitely because it's not necessary anymore
143+
/// // We drop the `data` explicitly because it's not necessary anymore
144144
/// // and the thread still has work to do. This allow other threads to
145145
/// // start working on the data immediately, without waiting
146146
/// // for the rest of the unrelated work to be done here.
147147
/// //
148148
/// // It's even more important here than in the threads because we `.join` the
149-
/// // threads after that. If we had not dropped the lock, a thread could be
149+
/// // threads after that. If we had not dropped the mutex guard, a thread could be
150150
/// // waiting forever for it, causing a deadlock.
151151
/// drop(data);
152-
/// // Here the lock is not assigned to a variable and so, even if the scope
152+
/// // Here the mutex guard is not assigned to a variable and so, even if the scope
153153
/// // does not end after this line, the mutex is still released:
154154
/// // there is no deadlock.
155155
/// *res_mutex.lock().unwrap() += result;

0 commit comments

Comments
 (0)