Changeset 18617 for trunk/FACT++


Ignore:
Timestamp:
09/18/16 11:16:18 (8 years ago)
Author:
tbretz
Message:
This looks like a solution. I start a second detached thread which does nothing else than wait for the first to finish. In this way, it is joined and joinable returns 0 as soon as the thread has stopped execution.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/EventBuilderWrapper.h

    r18266 r18617  
    352352    bool IsThreadRunning()
    353353    {
    354         if (fThreadMain.get_id()==boost::this_thread::get_id())
    355             return true;
    356         return !fThreadMain.timed_join(boost::posix_time::microseconds(0));
     354        return fThreadMain.joinable();
    357355    }
    358356
     
    382380
    383381        fThreadMain = boost::thread(StartEvtBuild);
     382
     383        // Run a detached thread which ensures that our thread
     384        // is joined so that it is not joinable anymore once
     385        // it is finished (I think this is similar to
     386        // boost::thread_guard, but I could not figure out
     387        // how it works)
     388        std::thread([this] { this->fThreadMain.join(); }).detach();
    384389    }
    385390
Note: See TracChangeset for help on using the changeset viewer.