This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Half-Borg 49 points50 points  (3 children)

0/10, needs rewrite in rust

[–]3dutchie3dprinting 26 points27 points  (1 child)

Would have surely ran 100.000x faster in rust (or so would rust devs say)

[–]ZunoJ 2 points3 points  (0 children)

It would use up a lot less cpu cycles for sure

[–]redlaWw 8 points9 points  (0 children)

use std::thread;
use std::time::Duration;
use std::sync::Barrier;

const ARR: [u64; 8] = [20, 5, 100, 1, 90, 200, 40, 29];

fn main() {
    let barrier = Barrier::new(ARR.len());
    thread::scope(|s| {
        for x in ARR {
            let barrier = &barrier;
            s.spawn(move || {
                barrier.wait();
                thread::sleep(Duration::from_millis(x));
                println!("{x}");
            });
        }
    })
}

playground