Boost logo

Boost Users :

Subject: Re: [Boost-users] Determining thread existence
From: Scott McMurray (me22.ca+boost_at_[hidden])
Date: 2009-04-08 14:41:23


On Wed, Apr 8, 2009 at 14:30, Jeremy Rottman <rottmanj_at_[hidden]> wrote:
> The main reason I want to remove the thread is when the daemon iterates, I
> do not want it to create new threads if threads are currently running. I am
> currently testing with 25 threads, the total thread count is dynamic. To sum
> it up, if threads are active and running, I do not want new threads to be
> created until no threads are active. The issue I am having is trying to
> determine if there are active threads still running code.
>

After join_all() has returned, there are no "active threads still
running code." This in no way implies a result of 0 from size().

It seems you're doing this:

thread_group tg;
while (something) {
    create_some_threads(tg, ...);
    tg.join_all();
}

and are disappointed that !tg.empty() when the loop restarts. Have
you considered just doing this?

while (something) {
    thread_group tg;
    create_some_threads(tg, ...);
    tg.join_all();
}


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