在 2019/6/29 上午12:10, Jacek Caban 写道: > > You don't really need to store the whole __gthr_win32_thr_desc in TLS. > If you stored just the handle, this wouldn't need a destructor. > >
The handle to be stored in the TLS ('the Handle' for short hereinafter) should be a real handle, so there are a few scenarios that we should consider: 0) the Handle should be closed upon the spawned thread's exit; in this case a destructor is still necessary to prevent handle leaks. 1) the Handle is closed by the creator via either `*_join()` or `*_detach()`; in the latter case the Handle becomes invalid while the thread is running, so `*_self()` would return an invalid handle. It seems inappropriate to use handles as thread identifiers (as handles imply resource ownership and are not unique identifiers); thread IDs (as `DWORD` or `unsigned long`) would be a better alternative. -- Best regards, LH_Mouse
signature.asc
Description: OpenPGP digital signature