Boost logo

Boost Users :

Subject: Re: [Boost-users] Get "Native" thread id - feature request
From: Ondrej Sluciak (ondrej.sluciak_at_[hidden])
Date: 2009-11-05 11:57:55


Yes I found such ideas, that you can map the thread::id to whatever you
want, but as you said, this can't do the job in some cases (like the one
with setting the thread name for windows debugger). I don't know if you
can call the ability of getting thread id a "hole" in the interface. It
is quite reasonable that when I create a thread using boost, I want to
know about the thread as much as possible, also by using boost..and
knowing its system id isn't actually that much. I don't really see how
this would break the portability of boost.
I agree that there are maybe many people who are on the "fence", just
like you, but there are many people who could appreciate this
functionality and find it very useful.

Nigel Rantor wrote:
> Ondrej Sluciak wrote:
>> Thank you for your hints. Well, it isn't just question of
>> SetThreadName function on Windows. The ability to get the real thread
>> id is quite crucial when you want to debug or when you want to log
>> also thread behaviour. On linux you are also interested in real pids.
>> I mean it would be really great if you could also set thread names
>> (and get thread names) directly using boost (and not using those
>> undocumented windows functions), but I don't know if there is some
>> general way how to do it on any OS, so I don't know if it would be
>> "feasible" to put it in boost. On the other hand, getting only thread
>> ids can be done on any OS (as far as I know). So at least this
>> functionality would be nice to have in boost.
>
> 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.
>
> n
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net