Skip to content

Commit c010e71

Browse files
committed
Rewrap comments in Mutex example
1 parent 34b3ff0 commit c010e71

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/libstd/sync/mutex.rs

+11-11
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 necessary to manually drop the mutex guard
112-
/// to unlock it sooner than the end of the enclosing scope.
111+
/// It is sometimes necessary to manually drop the mutex guard to unlock it
112+
/// sooner than the end of the enclosing scope.
113113
///
114114
/// ```
115115
/// use std::sync::{Arc, Mutex};
@@ -139,18 +139,18 @@ use crate::sys_common::poison::{self, LockResult, TryLockError, TryLockResult};
139139
/// // This is the result of some important and long-ish work.
140140
/// let result = data.iter().fold(0, |acc, x| acc + x * 2);
141141
/// data.push(result);
142-
/// // We drop the `data` explicitly because it's not necessary anymore
143-
/// // and the thread still has work to do. This allow other threads to
144-
/// // start working on the data immediately, without waiting
145-
/// // for the rest of the unrelated work to be done here.
142+
/// // We drop the `data` explicitly because it's not necessary anymore and the
143+
/// // thread still has work to do. This allow other threads to start working on
144+
/// // the data immediately, without waiting for the rest of the unrelated work
145+
/// // to be done here.
146146
/// //
147147
/// // It's even more important here than in the threads because we `.join` the
148-
/// // threads after that. If we had not dropped the mutex guard, a thread could be
149-
/// // waiting forever for it, causing a deadlock.
148+
/// // threads after that. If we had not dropped the mutex guard, a thread could
149+
/// // be waiting forever for it, causing a deadlock.
150150
/// drop(data);
151-
/// // Here the mutex guard is not assigned to a variable and so, even if the scope
152-
/// // does not end after this line, the mutex is still released:
153-
/// // there is no deadlock.
151+
/// // Here the mutex guard is not assigned to a variable and so, even if the
152+
/// // scope does not end after this line, the mutex is still released: there is
153+
/// // no deadlock.
154154
/// *res_mutex.lock().unwrap() += result;
155155
///
156156
/// threads.into_iter().for_each(|thread| {

0 commit comments

Comments
 (0)