Boost logo

Boost :

From: William Kempf (williamkempf_at_[hidden])
Date: 2002-04-10 09:25:41

>I believe there is a problem with tread_gruop::join_all() and
>the following code fragment will raise an assertion:
>boost::thread_group tg;
>tg.create_thread( ... )
>tg.create_thread( ... )
>tg.create_thread( ... )
>tg.create_thread( ... )
>tg.join_all() //this asserts false.
>I believe there are two problems here:
>1. join_all does'nt clean the inner list of threads, I believe that it
>can't do it since calling create_thread() returns a thread* that the
>client might refer to later.

That's not actually a reason not to empty the list.

>2.thread::join() ignores the m_joinable member and attempts the actual
>join operation even when it should'nt do so( i.e. default constructed
>threads ). The first iteration of thread_group::join_all to attempt to
>join all threads in the group including those already joined earlier,
>this of course fails.

Because it's a violation of the contract. You can argue the contract is
poorly written, but this behavior is under very close scrutiny right now for
changing any way.

>I believe that number 2 is the real problem here, and it can be solved
>with a simple if like the destructor does, another solution would be
>exposing a joinable() method that can be accessed before calling join().

I believe this behavior is going to be modified even more drastically then
what you're proposing. This is the weakest part of the current design.

So, basically, you've used boost::thread_group in a manner I didn't forsee.
Thanks for pointing this problem out. I'll try and resolve this issue soon,
though the right solution isn't readily appearant because of other decisions
being made about the nature of join(). So, short term I'll add a
boost::thread_group::clear() that will empty the thread group list and you
can use this to work around the problem you have.

Bill Kempf

Join the world’s largest e-mail service with MSN Hotmail.

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