mirror of
https://github.com/openharmony/third_party_rust_rust.git
synced 2026-07-19 11:43:39 -04: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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user