Date: 2001-07-02 13:14:51
--- In boost_at_y..., williamkempf_at_h... wrote:
> There are two problems here. First, as I pointed out the details
> hidden in the other concept, so the ease of use is not impacted.
> Second, you chose to use a ref-count design internally, when such a
> design is not needed.
> class thread_group
> // all implicit members are fine and useful
> template<class F> void create(F f)
> v_.push_back(new thread(f));
> void join_all()
> std::vector<thread*>::iterator it = v_.begin();
> while (it != v_.end())
Ooops... that's what I get for doing this on the fly. You need the
following line as well:
> it = v_.erase(it);
> std::vector<thread*> v_;
I should also note that this is a poor implementation of a
thread_group, the destruction and removal from the group should
probably only be done in the object's destructor and no during the
call to join_all().
BTW, I think the confusion comes from my use of the term "explicit"
lifetime management. This doesn't mean "manual" lifetime
management. It means there may be multiple references, but only one
owner, who is responsible for managing the lifetime, whether this is
through manual means or through proper use of RAII constructs.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk