|
Boost Users : |
From: Roland Schwarz (roland.schwarz_at_[hidden])
Date: 2004-12-12 15:00:48
Peter Dimov wrote:
>
> pthread_self gives you a full pthread_t, which you can use as input to
> pthread_join, pthread_cancel, pthread_setschedparam; you can also give
> this pthread_t to another thread and it remains valid.
>
> boost::thread::thread() doesn't give you a boost::thread*, the
> boost::thread surrogate it creates is valid only within the current
> thread, and it can only be compared to another boost::thread.
>
> pthread_self "always works"; it does not depend on some user not
> destroying a boost::thread object. A boost::thread* in thread-specific
> storage does not have this property.
Ah, I see. Thank you. Now I understand why W.E.Kempf has given up on the
bool m_joinable;
attribute in his newer work on thread. He introduced a thread_data
structure
that lives in tls storage and serves the purposes of pthread_self.
The default constructor now essentially is:
thread::thread()
: m_handle(0)
{
thread_data* tdata = thread_data::get_current();
tdata->addref();
m_handle = tdata;
}
And this does give back something that can be used as long as the thread
is alive.
Roland
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