Boost logo

Boost :

From: William Kempf (williamkempf_at_[hidden])
Date: 2002-04-04 10:07:12


>From: "Hoeffner, Detlef" <Detlef.Hoeffner_at_[hidden]>
>Reply-To: boost_at_[hidden]
>To: "'boost_at_[hidden]'" <boost_at_[hidden]>
>Subject: RE: [boost] Thread locals
>Date: Wed, 3 Apr 2002 18:53:55 +0200
>
>Hi William,
>
> > However, I understand the convenience of this and so
> > I'll add something soon. Thanks for the suggestion.
>
>Thanks!
>
> > The only thing missing in boost::thread from your list is
> > operator<<(ostream&, ).
>
>I still do not see how I would identify the current instance of thread.
>Am I missing something?

The default constructor creates a boost::thread for the current thread, and
boost::thread has == and != operators that can then be used for the
comparison. Again, the only thing missing from your list was a way to
output and identifying textual representation. Though to really be useful
we also need a copyable form of ID.

> > I'm going to work around this by using a TSS pointer value,
> > which seems to be the best solution, though it's not a perfect solution.
>
>I guess for performance issues it would be preferable to use functions the
>operating system or the thread library provides, e.g.
>
> static thread_id getCurrentThreadId()
> {
>#ifdef POSIX_THREADS
> return pthread_self();
>#elif WIN32_THREADS
> return GetCurrentThreadId();
>#endif
> }

The reasons to not do this:

1. It doesn't provide a means for outputting a textual representation.

2. It doesn't provide LessThanComparable semantics, so it can't be used as a
key in a set/map, which isn't in your list of needs but is still something I
think we need.

Bill Kempf
williamkempf_at_[hidden]

_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx


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