From e1c052627ec3ffc2d83a5d81f159b21608910ed9 Mon Sep 17 00:00:00 2001 From: claddy <0xcladdy@gmail.com> Date: Mon, 16 Dec 2024 23:21:25 +0530 Subject: [PATCH] Add logs when 'join_all_threads' is used --- src/maker/api.rs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/maker/api.rs b/src/maker/api.rs index 203600e7..e3abe637 100644 --- a/src/maker/api.rs +++ b/src/maker/api.rs @@ -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(()) } } @@ -787,4 +808,4 @@ pub fn recover_from_swap( }; std::thread::sleep(block_lookup_interval); } -} \ No newline at end of file +}