Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-09-24 14:57:10


From: <williamkempf_at_[hidden]>
> --- In boost_at_y..., "Peter Dimov" <pdimov_at_m...> wrote:
> > class thread
> > {
> > unsigned long id() const; // uniquely identifies the thread
> > };
> >
> > What do you think?
>
> I think it's a pain in the @$$ to implement on POSIX ;).

I think that it's doable. You'd need a get_next_id() thread safe function.

> Seriously, though, I did consider this and rejected it, at least for
> the short term, because it is difficult to define for POSIX
> implementations. The "ID" on POSIX systems is an opaque type, and is
> likely a pointer and not an integral value. For most purposes you
> don't really need this method any way, since we support operators ==
> and != (I realize this isn't enough for collation, but since
> boost::thread isn't copyable there's not a lot of need for full
> collation).

The problem is that I think that I do need it; in Boost.Threads I can't make
a std::map<> keyed on a thread, and even if I could (my thread::ref can be a
map key) a thread id could be useful for other purposes. For example, how
can I implement an errorcheck mutex?

--
Peter Dimov
Multi Media Ltd.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk