Use all cores (#8908)
This commit is contained in:
@ -534,13 +534,14 @@ fn do_main(matches: &ArgMatches<'_>) -> Result<(), Box<dyn error::Error>> {
|
|||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
let done = Arc::new(AtomicBool::new(false));
|
let done = Arc::new(AtomicBool::new(false));
|
||||||
|
|
||||||
for _ in 0..num_cpus::get() {
|
let thread_handles: Vec<_> = (0..num_cpus::get())
|
||||||
|
.map(|_| {
|
||||||
let done = done.clone();
|
let done = done.clone();
|
||||||
let attempts = attempts.clone();
|
let attempts = attempts.clone();
|
||||||
let found = found.clone();
|
let found = found.clone();
|
||||||
let grind_matches_thread_safe = grind_matches_thread_safe.clone();
|
let grind_matches_thread_safe = grind_matches_thread_safe.clone();
|
||||||
|
|
||||||
let handle = thread::spawn(move || loop {
|
thread::spawn(move || loop {
|
||||||
if done.load(Ordering::Relaxed) {
|
if done.load(Ordering::Relaxed) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -579,7 +580,10 @@ fn do_main(matches: &ArgMatches<'_>) -> Result<(), Box<dyn error::Error>> {
|
|||||||
grind_matches_thread_safe[i]
|
grind_matches_thread_safe[i]
|
||||||
.count
|
.count
|
||||||
.fetch_sub(1, Ordering::Relaxed);
|
.fetch_sub(1, Ordering::Relaxed);
|
||||||
println!("Wrote keypair to {}", &format!("{}.json", keypair.pubkey()));
|
println!(
|
||||||
|
"Wrote keypair to {}",
|
||||||
|
&format!("{}.json", keypair.pubkey())
|
||||||
|
);
|
||||||
write_keypair_file(&keypair, &format!("{}.json", keypair.pubkey()))
|
write_keypair_file(&keypair, &format!("{}.json", keypair.pubkey()))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
@ -587,8 +591,12 @@ fn do_main(matches: &ArgMatches<'_>) -> Result<(), Box<dyn error::Error>> {
|
|||||||
if total_matches_found == grind_matches_thread_safe.len() {
|
if total_matches_found == grind_matches_thread_safe.len() {
|
||||||
done.store(true, Ordering::Relaxed);
|
done.store(true, Ordering::Relaxed);
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
handle.join().unwrap();
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
for thread_handle in thread_handles {
|
||||||
|
thread_handle.join().unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
("verify", Some(matches)) => {
|
("verify", Some(matches)) => {
|
||||||
|
Reference in New Issue
Block a user