Skip to content

Commit

Permalink
Rollup merge of #113202 - guilliamxavier:patch-1, r=workingjubilee
Browse files Browse the repository at this point in the history
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?)
  • Loading branch information
matthiaskrgr authored Jul 2, 2023
2 parents 2a3766e + e34ff93 commit c4ba0a6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions library/std/src/sync/barrier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit c4ba0a6

Please sign in to comment.