Skip to content

Commit 1312d30

Browse files
committed
Remove a lot of unecessary/duplicated comments
1 parent fdef1a5 commit 1312d30

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

src/libstd/sync/mutex.rs

+3-11
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,11 @@ use crate::sys_common::poison::{self, LockResult, TryLockError, TryLockResult};
118118
///
119119
/// const N: usize = 3;
120120
///
121-
/// // Some data to work with in multiple threads.
122121
/// let data_mutex = Arc::new(Mutex::new(vec![1, 2, 3, 4]));
123-
/// // The result of all the work across all threads.
124122
/// let res_mutex = Arc::new(Mutex::new(0));
125123
///
126-
/// // Threads other than the main thread.
127124
/// let mut threads = Vec::with_capacity(N);
128125
/// (0..N).for_each(|_| {
129-
/// // Getting clones for the mutexes.
130126
/// let data_mutex_clone = Arc::clone(&data_mutex);
131127
/// let res_mutex_clone = Arc::clone(&res_mutex);
132128
///
@@ -135,10 +131,6 @@ use crate::sys_common::poison::{self, LockResult, TryLockError, TryLockResult};
135131
/// // This is the result of some important and long-ish work.
136132
/// let result = data.iter().fold(0, |acc, x| acc + x * 2);
137133
/// data.push(result);
138-
/// // We drop the `data` explicitely because it's not necessary anymore
139-
/// // and the thread still has work to do. This allow other threads to
140-
/// // start working on the data immediately, without waiting
141-
/// // for the rest of the unrelated work to be done here.
142134
/// drop(data);
143135
/// *res_mutex_clone.lock().unwrap() += result;
144136
/// }));
@@ -153,9 +145,9 @@ use crate::sys_common::poison::{self, LockResult, TryLockError, TryLockResult};
153145
/// // start working on the data immediately, without waiting
154146
/// // for the rest of the unrelated work to be done here.
155147
/// //
156-
/// // It's even more important here because we `.join` the threads after that.
157-
/// // If we had not dropped the lock, a thread could be waiting forever for
158-
/// // it, causing a deadlock.
148+
/// // 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
150+
/// // waiting forever for it, causing a deadlock.
159151
/// drop(data);
160152
/// // Here the lock is not assigned to a variable and so, even if the scope
161153
/// // does not end after this line, the mutex is still released:

0 commit comments

Comments
 (0)