Cleaning up

Lastly we clean up after ourselves by joining all our threads so we know that all destructors have ran without errors after we're finished.

// We clean up our resources, make sure all destructors run.
for thread in self.thread_pool.into_iter() {
    thread.sender.send(Event::close()).expect("threadpool cleanup");



Before we join the thread on our thread pool we send a Close event which unparks the thread and exits the loop we're in.

How we clean up after ourselves in minimio will be covered in the book that covers this topic specifically.

If you want to read more about why it's a good practice to join all threads and clean up after us before we exit, I can recommend the article Join Your Threads written by @matklad.