Skip to content

Commit

Permalink
Add logs when 'join_all_threads' is used
Browse files Browse the repository at this point in the history
  • Loading branch information
claddyy committed Dec 16, 2024
1 parent aa450b6 commit 9fa4951
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/maker/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,30 @@ impl ThreadPool {
.threads
.lock()
.map_err(|_| MakerError::General("Failed to lock threads"))?;

let thread_count = threads.len();
log::info!("Joining {} threads", thread_count);

let mut joined_count = 0;
while let Some(thread) = threads.pop() {
thread.join().unwrap();
let thread_name = thread.thread().name().unwrap().to_string();

match thread.join() {
Ok(_) => {
log::info!("Thread {} terminated successfully", thread_name);
joined_count += 1;
}
Err(e) => {
log::error!("Thread {} terminated due to error {:?}", thread_name, e);
}
}
}

log::info!(
"Successfully joined {} out of {} threads",
joined_count,
thread_count
);
Ok(())
}
}
Expand Down

0 comments on commit 9fa4951

Please sign in to comment.