notepad-plus-plus / nppShell

Provide Explorer context menu entry "Edit with Notepad++"
GNU General Public License v3.0
25 stars 13 forks source link

Remove unecessary global/external variable #28

Closed donho closed 1 year ago

donho commented 1 year ago

The thread variable is not necessary to be external and global.

donho commented 1 year ago

@GurliGebis Could you review this PR?

GurliGebis commented 1 year ago

@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.

donho commented 1 year ago

@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

GurliGebis commented 1 year ago

Okay, I'll take a look at it when I get home (I don't have access to my dev machine right now)

GurliGebis commented 1 year ago

@donho I just tested it, and you are right, the thread doesn't need to stay in scope. So this is fine to merge 🚀

donho commented 1 year ago

@GurliGebis Thank you for the reviewing and the test!

GurliGebis commented 1 year ago

@donho You're welcome