On Thu, Nov 5, 2009 at 10:39 AM, Nigel Rantor <wiggly@wiggly.org> wrote:

A question like this has come up before with respect to being able to identify threads.

If you only want to name threads then you can use the thread::get_id() function. The thread::id value provides a comparison operator so that you can use it in, for example a std::map<thread::id,std::string> to provide a mapping between boost ids and something more user-friendly.

Yes, this doesn't necessarily fit very well with a debugger but for lots of applications this is enough, to be able associate a "name" with a thread.

I understand why you want to be able to get to the "raw" id, and it would, in all probability, be a change that doesn't break anyone, but it does give people the temptation to break portability without thinking about other solutions that are open to them.

I'm on the fence basically. I wouldn't suggest breaking a hole in the interface to let you peek at the OS id but I also wouldn't spend too much energy arguing against it.


Since you wouldn't spend too much energy arguing against it I guess there's no point in my response here :)  But in any case, tons of libraries already expose things like this to get access to underlying os things.  even thread already does it for the native_handle().  iostreams::file_descriptor does it for the native handle too.  asio exposes native functionality to be able to use i/o completion ports on windows.  

Zach