|
Boost Users : |
From: Michael Glassford (glassfordm_at_[hidden])
Date: 2004-03-17 11:02:12
Peter Dimov wrote:
> Pete wrote:
>> I'm pretty convinced that there is a serious design flaw in
>> boost::thread_group or at the very minimum, the documentation
should
>> better address the issue.
>
> 'thread_group' is totally and utterly flawed and should never have
> been added to Boost.Threads in the first place. Use vector<
> shared_ptr<thread> >.
This is essentially what thread_group becomes in the Boost.Thread
version that's on the thread_dev branch. In that version, the thread
class becomes a handle class; each thread object contains a
reference-counted pointer to a thread_data object.
Only one thread_data object exists per thread, stored in a
thread_specific_ptr (which, as an aside, is why the
thread_specific_ptr class becomes more important, which is presumeably
why Bill Kemp removed support for the Win32 static library version of
Boost.Thread). When a thread object is created, it gets the associated
thread_data object (or creates one if there isn't one already) and
increments its reference count; when it detaches, it decrements the
reference count. When the thread_data object is no longer referenced
(which only happens when all thread objects and the
thread_specific_ptr stop referencing it), the thread_data pointer is
deleted and the thread is detached.
At least that's what I see in the code; I have yet to try it to see
how it works.
Mike
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