|
Boost : |
From: williamkempf_at_[hidden]
Date: 2001-08-25 15:26:47
--- In boost_at_y..., "Peter Dimov" <pdimov_at_m...> wrote:
> From: "William Kempf" <williamkempf_at_h...>
>
> [on adopting threads]
>
>
> > Have I made the issue clear enough now?
>
> Yes, thank you. An adopted thread doesn't know whether pthread_join
() or
> pthread_detach() has already been called.
>
> Ignoring the technical problems for now, why do you think that
adopting
> threads created by pthread_create() is a major QoI issue for a
standard C++
> thread library?
I've explained this before. When linking with other libraries (both
C and C++) it's quite possible that the library has created threads
using the "native" means, POSIX in this case. These libraries can
call back into code that calls boost::thread() (or equivalent "self"
functionality). At this point the thread must either be adopted, or
you must indicate some sort of error, and the only option that's
likely to be acceptable to users is to adopt the thread. Even
the "initial thread", as you've pointed out, is a thread created from
outside of Boost.Threads and so a thread that must be adopted. The
easiest and safest approach for Boost.Threads to take is therefore to
make such adopted threads "non-joinable", and for symetry this means
all thread objects created for the current thread need be "non-
joinable".
Bill Kempf
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk