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 e1c0526
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions 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);

Check warning on line 143 in src/maker/api.rs

View check run for this annotation

Codecov / codecov/patch

src/maker/api.rs#L142-L143

Added lines #L142 - L143 were not covered by tests
}
}
}

log::info!(
"Successfully joined {} out of {} threads",
joined_count,
thread_count

Check warning on line 151 in src/maker/api.rs

View check run for this annotation

Codecov / codecov/patch

src/maker/api.rs#L150-L151

Added lines #L150 - L151 were not covered by tests
);
Ok(())
}
}
Expand Down Expand Up @@ -787,4 +808,4 @@ pub fn recover_from_swap(
};
std::thread::sleep(block_lookup_interval);
}
}
}

0 comments on commit e1c0526

Please sign in to comment.