Closed donho closed 1 year ago
@GurliGebis Could you review this PR?
@donho I'll take a look and get back to you. The reason for making it global was to make sure it lives long enough for it to finish before the object is destroyed.
@GurliGebis
The reason for making it global was to make sure it lives long enough for it to finish before the object is destroyed.
I'm not an expert of thread, But after checking some document/suggestion about detach(), once detach method is called, the thread will live its own life and the object/instance of thread in the block is no more valid.
https://cplusplus.com/reference/thread/thread/detach/
https://stackoverflow.com/questions/22803600/when-should-i-use-stdthreaddetach
Okay, I'll take a look at it when I get home (I don't have access to my dev machine right now)
@donho I just tested it, and you are right, the thread doesn't need to stay in scope. So this is fine to merge 🚀
@GurliGebis Thank you for the reviewing and the test!
@donho You're welcome
The thread variable is not necessary to be external and global.