mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Rollup merge of #113202 - guilliamxavier:patch-1, r=workingjubilee
std docs: factorize literal in Barrier example Motivated by https://www.reddit.com/r/rust/comments/rnh5hu/barrier_question_barrier_does_not_sync_many/ (but maybe not worth it?)
This commit is contained in:
commit
c4ba0a6912
@ -13,9 +13,10 @@ use crate::sync::{Condvar, Mutex};
|
||||
/// use std::sync::{Arc, Barrier};
|
||||
/// use std::thread;
|
||||
///
|
||||
/// let mut handles = Vec::with_capacity(10);
|
||||
/// let barrier = Arc::new(Barrier::new(10));
|
||||
/// for _ in 0..10 {
|
||||
/// let n = 10;
|
||||
/// let mut handles = Vec::with_capacity(n);
|
||||
/// let barrier = Arc::new(Barrier::new(n));
|
||||
/// for _ in 0..n {
|
||||
/// let c = Arc::clone(&barrier);
|
||||
/// // The same messages will be printed together.
|
||||
/// // You will NOT see any interleaving.
|
||||
@ -105,9 +106,10 @@ impl Barrier {
|
||||
/// use std::sync::{Arc, Barrier};
|
||||
/// use std::thread;
|
||||
///
|
||||
/// let mut handles = Vec::with_capacity(10);
|
||||
/// let barrier = Arc::new(Barrier::new(10));
|
||||
/// for _ in 0..10 {
|
||||
/// let n = 10;
|
||||
/// let mut handles = Vec::with_capacity(n);
|
||||
/// let barrier = Arc::new(Barrier::new(n));
|
||||
/// for _ in 0..n {
|
||||
/// let c = Arc::clone(&barrier);
|
||||
/// // The same messages will be printed together.
|
||||
/// // You will NOT see any interleaving.
|
||||
|
Loading…
Reference in New Issue
Block a user