Boost logo

Boost :

From: William Kempf (williamkempf_at_[hidden])
Date: 2002-04-03 10:04:54

>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 16:37:41 +0200
> > As a substitute, try using the comparison operator for the boost::thread
> > class. This can fill the gap in many (but not all) cases where you are
> > managing the set of threads yourself.
>I need this mainly for tracing purposes in spots where I have no knowledge
>of the current instance of thread. This does not seem to help me in that
> > On some platforms (i.e. pthreads), the "thread_id" is actually an opaque
> > type (pthread_t) rather than a numeric value, and I think that is why no
> > such operation is exposed in the current version of the library.
>It is however possible to provide a class threadid, that has dependent on
>platform different members but provides operations as ==, !=,
>operator<<(ostream&, ), ... That would be fine to solve the problem.

The only thing missing in boost::thread from your list is
operator<<(ostream&, ). That's actually the tricky one to do portably. The
pthread_t opaque type provides no way to output a unique textual
representation. 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.

BTW, there's another operation needed for thread_id that you didn't
mention... it needs to be copy constructable.

Bill Kempf

Chat with friends online, try MSN Messenger:

Boost list run by bdawes at, gregod at, cpdaniel at, john at