Bug in phobos Thread module?

Babele Dunnit babele.dunnit at gmail.com
Fri May 11 09:38:12 PDT 2007


Hi all,

I am a newbie with D but experienced C++ developer.. this is my first post, so I MUST say that D ROCKS! Really impressive language. Walter, you are definitely the Lord of Compilers. Back to the subject, I am writing a massively multithreaded piece of code, and after some time I get a "failed to start" error. I digged in the forums and found someone else with same problem, but no answer. So was time to dig into Thread sources...

...and I see a static destructor cleaning a single handle (the main thread, I suppose), but no CloseHandle on any other handle created via _beginthreadex (I am talking about Windows, I should have specified before, sorry). 

I believe there should be an explicit Thread destructor able to free the handle via CloseHandle; also, because thread handles under Windows are a limited resource, probably a RIAA scheme (or explicit "delete" call) should be used, instead of waiting for the GC to pass by..

So, I added a CloseHandle(mythread.hdl) call and now my handles count (in the Task Manager) is much more under control...

ciao
Bab




More information about the Digitalmars-d mailing list