Boost logo

Boost Users :

Subject: [Boost-users] Determining thread existence
From: Jeremy Rottman (rottmanj_at_[hidden])
Date: 2009-04-07 14:45:27


I am trying to setup my application so that it runs as a daemon. One
aspect that I need to run a sanity check on is to determine if there are
currently any parent threads running.

Currently this is what I am testing with, when all threads are finish
running, I then join all the threads to terminate them. Doing so should
give me a thread group size of 0. However, this is now the case.
Currently after I join the threads, the thread group size is still 0.

Here is my current test code that I am working with. Any help with this
is greatly appreciated.

int main(int argc, char *argv[]) {

    InitConfig mconfig;

    if(mconfig.setConfig()){

        boost::thread_group Tg;

                cout << "Thread Size Before: " << Tg.size() << endl;
               // DISPLAYS 0
                for(int i = 1; i < 25; i++){
                    dmParse parse;
                    Tg.create_thread(boost::bind(&dmParse::onInit,parse,i));
                }

                cout << "Thread Size: " << Tg.size() << endl;
                  // DISPLAYS 24

                Tg.join_all();
                cout << "Thread Count After:" << Tg.size() << endl;
            // DISPLAYS 24
}


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