fn test() {
let mut channels = Arc::new(Mutex::new(Vec::with_capacity(PAR)));
for _ in 0..N/PAR {
let mut joins = Vec::with_capacity(PAR);
for _ in 0..PAR {
let mut channels = Arc::clone(&channels);
joins.push(thread::spawn(move || {
get(&mut channels.lock().unwrap());
}));
}
}
}
#[inline(always)]
fn get(channels: &mut MutexGuard<Vec<mpsc::Sender<i32>>>) -> i32{
let (tx, rx) = mpsc::channel();
channels.push(tx);
if channels.len() == PAR {
exec(channels);
}
rx.recv().unwrap()
}
#[inline(always)]
fn exec(channels: &mut MutexGuard<Vec<mpsc::Sender<i32>>>) {
let mut i = 0;
for c in channels.iter() {
i += 1;
c.send(1).unwrap();
}
println!("{}", i);
channels.clear();
}
Мне не было интересно врываться в интернет с новой библиотекой
Step 5/11 : RUN cargo build --release
---> Running in 1f144422e617
error: failed to parse manifest at `/test-tcp/Cargo.toml`
Caused by:
no targets specified in the manifest
either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present
Error response from daemon: The command '/bin/sh -c cargo build --release' returned a non-zero code: 101
Failed to deploy '<unknown> Dockerfile: bench2/Dockerfile': Can't retrieve image ID from build stream
RUN cargo build --release
RUN rm src/*.rs
docker build -t bench2_linux .
docker run bench2_linux
Hello, world!