mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 15:32:06 +00:00
std docs: factorize literal in Barrier example
This commit is contained in:
parent
56d507dc92
commit
e34ff93c6b
@ -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